Commit 8611b894 authored by Cathy Li's avatar Cathy Li Committed by Commit Bot

[ExploreSites]: Remove most visited and personalization from flags and code usages

Change-Id: Ia9237329cedb733e657912fc44a15688ae3bafd6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1806075Reviewed-by: default avatarJustin DeWitt <dewittj@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Cathy Li <chili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731736}
parent 22505317
...@@ -663,10 +663,8 @@ chrome_java_sources = [ ...@@ -663,10 +663,8 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategory.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategory.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryCardView.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryCardView.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryTile.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryTile.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryTileView.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesIPH.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesIPH.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesPage.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesPage.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesSection.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesSite.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesSite.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesTileView.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesTileView.java",
"java/src/org/chromium/chrome/browser/explore_sites/StableScrollLayoutManager.java", "java/src/org/chromium/chrome/browser/explore_sites/StableScrollLayoutManager.java",
......
...@@ -72,7 +72,6 @@ chrome_junit_test_java_sources = [ ...@@ -72,7 +72,6 @@ chrome_junit_test_java_sources = [
"junit/src/org/chromium/chrome/browser/explore_sites/ExploreSitesBackgroundTaskUnitTest.java", "junit/src/org/chromium/chrome/browser/explore_sites/ExploreSitesBackgroundTaskUnitTest.java",
"junit/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryUnitTest.java", "junit/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryUnitTest.java",
"junit/src/org/chromium/chrome/browser/explore_sites/ExploreSitesPageStateUnitTest.java", "junit/src/org/chromium/chrome/browser/explore_sites/ExploreSitesPageStateUnitTest.java",
"junit/src/org/chromium/chrome/browser/explore_sites/ExploreSitesSectionUnitTest.java",
"junit/src/org/chromium/chrome/browser/externalauth/ExternalAuthUtilsTest.java", "junit/src/org/chromium/chrome/browser/externalauth/ExternalAuthUtilsTest.java",
"junit/src/org/chromium/chrome/browser/feedback/FeedbackCollectorTest.java", "junit/src/org/chromium/chrome/browser/feedback/FeedbackCollectorTest.java",
"junit/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencerTest.java", "junit/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencerTest.java",
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<vector xmlns:tools="http://schemas.android.com/tools" tools:targetApi="21"
android:autoMirrored="true" android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@color/default_icon_color_blue" android:pathData="M19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM14,17L7,17v-2h7v2zM17,13L7,13v-2h10v2zM17,9L7,9L7,7h10v2z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<vector
xmlns:tools="http://schemas.android.com/tools" tools:targetApi="21"
xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp" android:width="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0">
<path android:fillColor="@color/default_icon_color_blue" android:pathData="M13.49,5.48c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM9.89,19.38l1,-4.4 2.1,2v6h2v-7.5l-2.1,-2 0.6,-3c1.3,1.5 3.3,2.5 5.5,2.5v-2c-1.9,0 -3.5,-1 -4.3,-2.4l-1,-1.6c-0.4,-0.6 -1,-1 -1.7,-1 -0.3,0 -0.5,0.1 -0.8,0.1l-5.2,2.2v4.7h2v-3.4l1.8,-0.7 -1.6,8.1 -4.9,-1 -0.4,2 7,1.4z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<vector android:height="24dp" android:width="24dp"
xmlns:tools="http://schemas.android.com/tools" tools:targetApi="21"
xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportHeight="24.0" android:viewportWidth="24.0">
<path android:fillColor="@color/default_icon_color_blue" android:pathData="M17.21,9l-4.38,-6.56c-0.19,-0.28 -0.51,-0.42 -0.83,-0.42 -0.32,0 -0.64,0.14 -0.83,0.43L6.79,9L2,9c-0.55,0 -1,0.45 -1,1 0,0.09 0.01,0.18 0.04,0.27l2.54,9.27c0.23,0.84 1,1.46 1.92,1.46h13c0.92,0 1.69,-0.62 1.93,-1.46l2.54,-9.27L23,10c0,-0.55 -0.45,-1 -1,-1h-4.79zM9,9l3,-4.4L15,9L9,9zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<org.chromium.chrome.browser.explore_sites.ExploreSitesCategoryTileView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/tile_view_width"
android:layout_height="wrap_content"
android:paddingStart="@dimen/tile_view_padding"
android:paddingEnd="@dimen/tile_view_padding" >
<include
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/tile_view_modern" />
</org.chromium.chrome.browser.explore_sites.ExploreSitesCategoryTileView>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<org.chromium.chrome.browser.explore_sites.ExploreSitesCategoryTileView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/tile_view_width_condensed"
android:layout_height="wrap_content"
android:paddingStart="@dimen/tile_view_padding"
android:paddingEnd="@dimen/tile_view_padding" >
<include
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/tile_view_modern_condensed" />
</org.chromium.chrome.browser.explore_sites.ExploreSitesCategoryTileView>
...@@ -31,25 +31,6 @@ public class ExploreSitesBridge { ...@@ -31,25 +31,6 @@ public class ExploreSitesBridge {
sCatalogForTesting = catalog; sCatalogForTesting = catalog;
} }
/**
* @Deprecated Please use getCatalog instead.
*
* Fetches the catalog data from disk for Explore surfaces.
*
* Callback will be called with |null| if an error occurred.
*/
@Deprecated
public static void getEspCatalog(
Profile profile, Callback<List<ExploreSitesCategory>> callback) {
if (sCatalogForTesting != null) {
callback.onResult(sCatalogForTesting);
return;
}
List<ExploreSitesCategory> result = new ArrayList<>();
ExploreSitesBridgeJni.get().getEspCatalog(profile, result, callback);
}
/** /**
* Retrieves the catalog data for Explore surfaces by attempting to retrieve the data from disk. * Retrieves the catalog data for Explore surfaces by attempting to retrieve the data from disk.
* *
...@@ -100,19 +81,6 @@ public class ExploreSitesBridge { ...@@ -100,19 +81,6 @@ public class ExploreSitesBridge {
ExploreSitesBridgeJni.get().getIcon(profile, siteID, callback); ExploreSitesBridgeJni.get().getIcon(profile, siteID, callback);
} }
/**
* Returns a Bitmap representing a summary of the sites available in the catalog for a specific
* category.
*/
public static void getCategoryImage(
Profile profile, int categoryID, int pixelSize, Callback<Bitmap> callback) {
if (sCatalogForTesting != null) {
callback.onResult(null);
return;
}
ExploreSitesBridgeJni.get().getCategoryImage(profile, categoryID, pixelSize, callback);
}
/** /**
* Returns a Bitmap representing a summary of the sites available in the catalog. * Returns a Bitmap representing a summary of the sites available in the catalog.
*/ */
...@@ -156,15 +124,6 @@ public class ExploreSitesBridge { ...@@ -156,15 +124,6 @@ public class ExploreSitesBridge {
return ExploreSitesBridgeJni.get().getVariation(); return ExploreSitesBridgeJni.get().getVariation();
} }
/**
* Gets the current Finch variation for last MostLikely icon that is configured by flag or
* experiment.
*/
@MostLikelyVariation
public static int getIconVariation() {
return ExploreSitesBridgeJni.get().getIconVariation();
}
/** /**
* Gets the current Finch variation for dense that is configured by flag or experiment. * Gets the current Finch variation for dense that is configured by flag or experiment.
* */ * */
...@@ -174,9 +133,7 @@ public class ExploreSitesBridge { ...@@ -174,9 +133,7 @@ public class ExploreSitesBridge {
} }
public static boolean isEnabled(@ExploreSitesVariation int variation) { public static boolean isEnabled(@ExploreSitesVariation int variation) {
return variation == ExploreSitesVariation.ENABLED return variation == ExploreSitesVariation.ENABLED;
|| variation == ExploreSitesVariation.PERSONALIZED
|| variation == ExploreSitesVariation.MOST_LIKELY;
} }
public static boolean isExperimental(@ExploreSitesVariation int variation) { public static boolean isExperimental(@ExploreSitesVariation int variation) {
...@@ -187,18 +144,6 @@ public class ExploreSitesBridge { ...@@ -187,18 +144,6 @@ public class ExploreSitesBridge {
return variation != DenseVariation.ORIGINAL; return variation != DenseVariation.ORIGINAL;
} }
public static boolean isIntegratedWithMostLikely(@ExploreSitesVariation int variation) {
return variation == ExploreSitesVariation.MOST_LIKELY;
}
/**
* Increments the ntp_shown_count for a particular category.
* @param categoryId the row id of the category to increment show count for.
*/
public static void incrementNtpShownCount(Profile profile, int categoryId) {
ExploreSitesBridgeJni.get().incrementNtpShownCount(profile, categoryId);
}
@CalledByNative @CalledByNative
static void scheduleDailyTask() { static void scheduleDailyTask() {
ExploreSitesBackgroundTask.schedule(false /* updateCurrent */); ExploreSitesBackgroundTask.schedule(false /* updateCurrent */);
...@@ -222,19 +167,13 @@ public class ExploreSitesBridge { ...@@ -222,19 +167,13 @@ public class ExploreSitesBridge {
@NativeMethods @NativeMethods
interface Natives { interface Natives {
int getVariation(); int getVariation();
int getIconVariation();
int getDenseVariation(); int getDenseVariation();
void getEspCatalog(Profile profile, List<ExploreSitesCategory> result,
Callback<List<ExploreSitesCategory>> callback);
void getIcon(Profile profile, int siteID, Callback<Bitmap> callback); void getIcon(Profile profile, int siteID, Callback<Bitmap> callback);
void updateCatalogFromNetwork( void updateCatalogFromNetwork(
Profile profile, boolean isImmediateFetch, Callback<Boolean> callback); Profile profile, boolean isImmediateFetch, Callback<Boolean> callback);
void getCategoryImage(
Profile profile, int categoryID, int pixelSize, Callback<Bitmap> callback);
void getSummaryImage(Profile profile, int pixelSize, Callback<Bitmap> callback); void getSummaryImage(Profile profile, int pixelSize, Callback<Bitmap> callback);
void blacklistSite(Profile profile, String url); void blacklistSite(Profile profile, String url);
void recordClick(Profile profile, String url, int type); void recordClick(Profile profile, String url, int type);
void incrementNtpShownCount(Profile profile, int categoryId);
void getCatalog(Profile profile, int source, List<ExploreSitesCategory> result, void getCatalog(Profile profile, int source, List<ExploreSitesCategory> result,
Callback<List<ExploreSitesCategory>> callback); Callback<List<ExploreSitesCategory>> callback);
void initializeCatalog(Profile profile, int source); void initializeCatalog(Profile profile, int source);
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.explore_sites;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.compositor.animation.CompositorAnimationHandler;
import org.chromium.chrome.browser.ntp.TitleUtil;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.suggestions.tile.TileWithTextView;
/**
* A category tile for ExploreSites, containing an icon that is a composition of sites' favicons
* within the category. Alternatively, a MORE button.
*/
public class ExploreSitesCategoryTileView extends TileWithTextView {
private static final int FADE_ANIMATION_TIME_MS = 300;
private static final int TITLE_LINES = 1;
private static final boolean SUPPORTED_OFFLINE = false;
/** The data currently associated to this tile. */
private ExploreSitesCategory mCategory;
/**
* Constructor for inflating from XML.
*/
public ExploreSitesCategoryTileView(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* Initializes the view using the data held by {@code tile}. This should be called immediately
* after inflation.
* @param category The object that holds the data to populate this view.
*/
public void initialize(ExploreSitesCategory category, Profile profile) {
super.initialize(TitleUtil.getTitleForDisplay(category.getTitle(), category.getUrl()),
SUPPORTED_OFFLINE, category.getDrawable(), TITLE_LINES);
mCategory = category;
// Correct the properties of the icon for categories, it should be the entire size of the
// icon background now.
mIconView.setScaleType(ImageView.ScaleType.CENTER);
MarginLayoutParams layoutParams = (MarginLayoutParams) mIconView.getLayoutParams();
int tileViewIconSize =
getContext().getResources().getDimensionPixelSize(R.dimen.tile_view_icon_size);
layoutParams.width = tileViewIconSize;
layoutParams.height = tileViewIconSize;
layoutParams.topMargin = getContext().getResources().getDimensionPixelSize(
R.dimen.tile_view_icon_background_margin_top_modern);
mIconView.setLayoutParams(layoutParams);
Context context = getContext();
if (mCategory.getType() == ExploreSitesCategory.CategoryType.MORE_BUTTON) {
ExploreSitesIPH.configureIPH(this, profile);
}
}
/** Retrieves url associated with this view. */
public String getUrl() {
return mCategory.getUrl();
}
public ExploreSitesCategory getCategory() {
return mCategory;
}
/** Renders icon based on tile data. */
public void renderIcon(ExploreSitesCategory category) {
mCategory = category;
// If the category is a placeholder, just instantly render it, as we can assume there has
// been no appreciable delay since the NTP was initialized.
if (mCategory.isPlaceholder()) {
setIconDrawable(category.getDrawable());
return;
}
fadeThumbnailIn(category.getDrawable());
}
private void fadeThumbnailIn(Drawable thumbnail) {
int duration = FADE_ANIMATION_TIME_MS;
// If animations are disabled, just show the thumbnail.
if (CompositorAnimationHandler.isInTestingMode()) {
setIconDrawable(thumbnail);
return;
}
// We have some transition time, but no existing icon. TransitionDrawable requires two or
// more drawables to crossfade, so manually fade in here.
if (mIconView.getDrawable() == null) {
mIconView.setImageDrawable(thumbnail);
mIconView.setAlpha(0.0f);
mIconView.animate().alpha(1.0f).setDuration(duration).start();
return;
}
mIconView.animate()
.alpha(0.0f)
.setDuration(duration / 2)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mIconView.setImageDrawable(thumbnail);
mIconView.animate().alpha(1.0f).setDuration(duration / 2).start();
}
})
.start();
}
}
...@@ -52,8 +52,7 @@ import java.util.List; ...@@ -52,8 +52,7 @@ import java.util.List;
public class ExploreSitesPage extends BasicNativePage { public class ExploreSitesPage extends BasicNativePage {
private static final long BACK_NAVIGATION_TIMEOUT_FOR_UMA = DateUtils.SECOND_IN_MILLIS * 30; private static final long BACK_NAVIGATION_TIMEOUT_FOR_UMA = DateUtils.SECOND_IN_MILLIS * 30;
private static final String CONTEXT_MENU_USER_ACTION_PREFIX = "ExploreSites"; private static final String CONTEXT_MENU_USER_ACTION_PREFIX = "ExploreSites";
private static final int INITIAL_SCROLL_POSITION = 3; private static final int INITIAL_SCROLL_POSITION = 0;
private static final int INITIAL_SCROLL_POSITION_PERSONALIZED = 0;
private static final String NAVIGATION_ENTRY_PAGE_STATE_KEY = "ExploreSitesPageState"; private static final String NAVIGATION_ENTRY_PAGE_STATE_KEY = "ExploreSitesPageState";
// Constants that dictate sizes of rows and columns // Constants that dictate sizes of rows and columns
private static final int MAX_COLUMNS_DENSE_TITLE_BOTTOM = 5; private static final int MAX_COLUMNS_DENSE_TITLE_BOTTOM = 5;
...@@ -270,13 +269,7 @@ public class ExploreSitesPage extends BasicNativePage { ...@@ -270,13 +269,7 @@ public class ExploreSitesPage extends BasicNativePage {
} }
}); });
// We don't want to scroll to the 4th category if personalized mInitialScrollPosition = INITIAL_SCROLL_POSITION;
// or integrated with Most Likely.
int variation = ExploreSitesBridge.getVariation();
mInitialScrollPosition = variation == ExploreSitesVariation.PERSONALIZED
|| ExploreSitesBridge.isIntegratedWithMostLikely(variation)
? INITIAL_SCROLL_POSITION_PERSONALIZED
: INITIAL_SCROLL_POSITION;
ExploreSitesBridge.getCatalog(mProfile, ExploreSitesBridge.getCatalog(mProfile,
ExploreSitesCatalogUpdateRequestSource.EXPLORE_SITES_PAGE, this::translateToModel); ExploreSitesCatalogUpdateRequestSource.EXPLORE_SITES_PAGE, this::translateToModel);
......
...@@ -36,7 +36,6 @@ import org.chromium.chrome.browser.download.DownloadOpenSource; ...@@ -36,7 +36,6 @@ import org.chromium.chrome.browser.download.DownloadOpenSource;
import org.chromium.chrome.browser.download.DownloadUtils; import org.chromium.chrome.browser.download.DownloadUtils;
import org.chromium.chrome.browser.explore_sites.ExperimentalExploreSitesSection; import org.chromium.chrome.browser.explore_sites.ExperimentalExploreSitesSection;
import org.chromium.chrome.browser.explore_sites.ExploreSitesBridge; import org.chromium.chrome.browser.explore_sites.ExploreSitesBridge;
import org.chromium.chrome.browser.explore_sites.ExploreSitesSection;
import org.chromium.chrome.browser.native_page.ContextMenuManager; import org.chromium.chrome.browser.native_page.ContextMenuManager;
import org.chromium.chrome.browser.ntp.NewTabPage.OnSearchBoxScrollListener; import org.chromium.chrome.browser.ntp.NewTabPage.OnSearchBoxScrollListener;
import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager; import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager;
...@@ -181,10 +180,7 @@ public class NewTabPageLayout extends LinearLayout implements TileGroup.Observer ...@@ -181,10 +180,7 @@ public class NewTabPageLayout extends LinearLayout implements TileGroup.Observer
insertSiteSectionView(); insertSiteSectionView();
int variation = ExploreSitesBridge.getVariation(); int variation = ExploreSitesBridge.getVariation();
if (ExploreSitesBridge.isEnabled(variation) if (ExploreSitesBridge.isExperimental(variation)) {
&& !ExploreSitesBridge.isIntegratedWithMostLikely(variation)) {
mExploreSectionView = ((ViewStub) findViewById(R.id.explore_sites_stub)).inflate();
} else if (ExploreSitesBridge.isExperimental(variation)) {
ViewStub exploreStub = findViewById(R.id.explore_sites_stub); ViewStub exploreStub = findViewById(R.id.explore_sites_stub);
exploreStub.setLayoutResource(R.layout.experimental_explore_sites_section); exploreStub.setLayoutResource(R.layout.experimental_explore_sites_section);
mExploreSectionView = exploreStub.inflate(); mExploreSectionView = exploreStub.inflate();
...@@ -236,11 +232,7 @@ public class NewTabPageLayout extends LinearLayout implements TileGroup.Observer ...@@ -236,11 +232,7 @@ public class NewTabPageLayout extends LinearLayout implements TileGroup.Observer
mSiteSectionViewHolder.bindDataSource(mTileGroup, tileRenderer); mSiteSectionViewHolder.bindDataSource(mTileGroup, tileRenderer);
int variation = ExploreSitesBridge.getVariation(); int variation = ExploreSitesBridge.getVariation();
if (ExploreSitesBridge.isEnabled(variation) if (ExploreSitesBridge.isExperimental(variation)) {
&& !ExploreSitesBridge.isIntegratedWithMostLikely(variation)) {
mExploreSection = new ExploreSitesSection(mExploreSectionView, profile,
mManager.getNavigationDelegate(), SuggestionsConfig.getTileStyle(mUiConfig));
} else if (ExploreSitesBridge.isExperimental(variation)) {
mExploreSection = new ExperimentalExploreSitesSection( mExploreSection = new ExperimentalExploreSitesSection(
mExploreSectionView, profile, mManager.getNavigationDelegate()); mExploreSectionView, profile, mManager.getNavigationDelegate());
} }
...@@ -419,14 +411,6 @@ public class NewTabPageLayout extends LinearLayout implements TileGroup.Observer ...@@ -419,14 +411,6 @@ public class NewTabPageLayout extends LinearLayout implements TileGroup.Observer
mSiteSectionView = SiteSection.inflateSiteSection(this); mSiteSectionView = SiteSection.inflateSiteSection(this);
ViewGroup.LayoutParams layoutParams = mSiteSectionView.getLayoutParams(); ViewGroup.LayoutParams layoutParams = mSiteSectionView.getLayoutParams();
layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT; layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
// If the explore sites section exists as its own section, then space it more closely.
int variation = ExploreSitesBridge.getVariation();
if (ExploreSitesBridge.isEnabled(variation)
&& !ExploreSitesBridge.isIntegratedWithMostLikely(variation)) {
((MarginLayoutParams) layoutParams).bottomMargin =
getResources().getDimensionPixelOffset(
R.dimen.tile_grid_layout_vertical_spacing);
}
mSiteSectionView.setLayoutParams(layoutParams); mSiteSectionView.setLayoutParams(layoutParams);
int insertionPoint = indexOfChild(mMiddleSpacer) + 1; int insertionPoint = indexOfChild(mMiddleSpacer) + 1;
......
...@@ -11,8 +11,6 @@ import androidx.annotation.LayoutRes; ...@@ -11,8 +11,6 @@ import androidx.annotation.LayoutRes;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.explore_sites.ExploreSitesBridge;
import org.chromium.chrome.browser.native_page.ContextMenuManager; import org.chromium.chrome.browser.native_page.ContextMenuManager;
import org.chromium.chrome.browser.ntp.cards.ItemViewType; import org.chromium.chrome.browser.ntp.cards.ItemViewType;
import org.chromium.chrome.browser.ntp.cards.NewTabPageViewHolder; import org.chromium.chrome.browser.ntp.cards.NewTabPageViewHolder;
...@@ -111,11 +109,6 @@ public class SiteSection extends OptionalLeaf implements TileGroup.Observer { ...@@ -111,11 +109,6 @@ public class SiteSection extends OptionalLeaf implements TileGroup.Observer {
} }
private static int getMaxTileRows() { private static int getMaxTileRows() {
if (ChromeFeatureList.isEnabled(ChromeFeatureList.EXPLORE_SITES)
&& !ExploreSitesBridge.isIntegratedWithMostLikely(
ExploreSitesBridge.getVariation())) {
return 1;
}
return 2; return 2;
} }
......
...@@ -24,7 +24,6 @@ import org.chromium.base.task.AsyncTask; ...@@ -24,7 +24,6 @@ import org.chromium.base.task.AsyncTask;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.explore_sites.ExploreSitesBridge; import org.chromium.chrome.browser.explore_sites.ExploreSitesBridge;
import org.chromium.chrome.browser.explore_sites.ExploreSitesIPH; import org.chromium.chrome.browser.explore_sites.ExploreSitesIPH;
import org.chromium.chrome.browser.explore_sites.MostLikelyVariation;
import org.chromium.chrome.browser.favicon.IconType; import org.chromium.chrome.browser.favicon.IconType;
import org.chromium.chrome.browser.favicon.LargeIconBridge; import org.chromium.chrome.browser.favicon.LargeIconBridge;
import org.chromium.chrome.browser.favicon.RoundedIconGenerator; import org.chromium.chrome.browser.favicon.RoundedIconGenerator;
...@@ -146,18 +145,8 @@ public class TileRenderer { ...@@ -146,18 +145,8 @@ public class TileRenderer {
tileView = (TopSitesTileView) LayoutInflater.from(parentView.getContext()) tileView = (TopSitesTileView) LayoutInflater.from(parentView.getContext())
.inflate(mTopSitesLayout, parentView, false); .inflate(mTopSitesLayout, parentView, false);
int iconVariation = ExploreSitesBridge.getIconVariation(); tile.setIcon(
if (iconVariation == MostLikelyVariation.ICON_ARROW) { VectorDrawableCompat.create(mResources, R.drawable.ic_apps_blue_24dp, mTheme));
tile.setIcon(VectorDrawableCompat.create(
mResources, R.drawable.ic_arrow_forward_blue_24dp, mTheme));
tile.setType(TileVisualType.ICON_REAL);
} else if (iconVariation == MostLikelyVariation.ICON_DOTS) {
tile.setIcon(VectorDrawableCompat.create(
mResources, R.drawable.ic_apps_blue_24dp, mTheme));
tile.setType(TileVisualType.ICON_REAL);
} else if (iconVariation == MostLikelyVariation.ICON_GROUPED) {
tile.setIcon(VectorDrawableCompat.create(
mResources, R.drawable.ic_apps_blue_24dp, mTheme));
tile.setType(TileVisualType.ICON_DEFAULT); tile.setType(TileVisualType.ICON_DEFAULT);
// One task to load actual icon. // One task to load actual icon.
...@@ -167,7 +156,6 @@ public class TileRenderer { ...@@ -167,7 +156,6 @@ public class TileRenderer {
(Bitmap img) (Bitmap img)
-> bridgeCallback.onLargeIconAvailable( -> bridgeCallback.onLargeIconAvailable(
img, Color.BLACK, false, IconType.FAVICON)); img, Color.BLACK, false, IconType.FAVICON));
}
} else { } else {
tileView = (SuggestionsTileView) LayoutInflater.from(parentView.getContext()) tileView = (SuggestionsTileView) LayoutInflater.from(parentView.getContext())
.inflate(mLayout, parentView, false); .inflate(mLayout, parentView, false);
......
...@@ -8,9 +8,6 @@ import android.content.Context; ...@@ -8,9 +8,6 @@ import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.util.AttributeSet; import android.util.AttributeSet;
import org.chromium.chrome.browser.explore_sites.ExploreSitesBridge;
import org.chromium.chrome.browser.explore_sites.MostLikelyVariation;
/** /**
* The view for a top sites tile. Displays the title of the site beneath a large icon. * The view for a top sites tile. Displays the title of the site beneath a large icon.
*/ */
...@@ -26,8 +23,7 @@ public class TopSitesTileView extends SuggestionsTileView { ...@@ -26,8 +23,7 @@ public class TopSitesTileView extends SuggestionsTileView {
protected void setIconViewLayoutParams(Tile tile) { protected void setIconViewLayoutParams(Tile tile) {
MarginLayoutParams params = (MarginLayoutParams) mIconView.getLayoutParams(); MarginLayoutParams params = (MarginLayoutParams) mIconView.getLayoutParams();
Resources resources = getResources(); Resources resources = getResources();
if (tile.getType() == TileVisualType.ICON_REAL if (tile.getType() == TileVisualType.ICON_REAL) {
&& ExploreSitesBridge.getIconVariation() == MostLikelyVariation.ICON_GROUPED) {
// Grouped icons have extra large size. // Grouped icons have extra large size.
params.width = resources.getDimensionPixelOffset( params.width = resources.getDimensionPixelOffset(
org.chromium.chrome.R.dimen.tile_view_icon_size); org.chromium.chrome.R.dimen.tile_view_icon_size);
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.explore_sites;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.chromium.base.test.BaseRobolectricTestRunner;
/**
* Unit tests for {@link ExploreSitesSection}
*/
@RunWith(BaseRobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class ExploreSitesSectionUnitTest {
private static final int ID = 1;
private static final int TYPE = 2;
private static final String TITLE = "foo";
@Test
public void categoriesWithInteractionCount() {
ExploreSitesCategory cat1 = new ExploreSitesCategory(ID, TYPE, TITLE, 0, 5);
ExploreSitesCategory cat2 = new ExploreSitesCategory(ID, TYPE, TITLE, 0, 4);
ExploreSitesCategory cat3 = new ExploreSitesCategory(ID, TYPE, TITLE, 0, 3);
ExploreSitesCategory cat4 = new ExploreSitesCategory(ID, TYPE, TITLE, 3, 0);
// Interaction is sorted in descending order.
// 5 > 4, so 5 is first.
assertTrue(ExploreSitesSection.compareCategoryPriority(cat1, cat2) < 0);
// 3 < 4, so 4 is first.
assertTrue(ExploreSitesSection.compareCategoryPriority(cat3, cat2) > 0);
// 5 == 5.
assertEquals(0, ExploreSitesSection.compareCategoryPriority(cat1, cat1));
// 0s are not treated special.
assertTrue(ExploreSitesSection.compareCategoryPriority(cat3, cat4) < 0);
}
@Test
public void categoriesWithShownCount() {
ExploreSitesCategory cat1 = new ExploreSitesCategory(ID, TYPE, TITLE, 2, 0);
ExploreSitesCategory cat2 = new ExploreSitesCategory(ID, TYPE, TITLE, 4, 0);
ExploreSitesCategory cat3 = new ExploreSitesCategory(ID, TYPE, TITLE, 5, 0);
ExploreSitesCategory cat4 = new ExploreSitesCategory(ID, TYPE, TITLE, 3, 0);
// Mods are sorted first in descending order.
// 4 % 3 < 5 % 3, so 5 is first.
assertTrue(ExploreSitesSection.compareCategoryPriority(cat2, cat3) > 0);
// 2 % 3 > 4 % 3, so 2 is first.
assertTrue(ExploreSitesSection.compareCategoryPriority(cat1, cat2) < 0);
// If mods are equal, sort by integer division in ascending order.
// 2 / 3 < 5 / 3, so 2 is first
assertTrue(ExploreSitesSection.compareCategoryPriority(cat1, cat3) < 0);
// If everything is equal, return equal.
assertEquals(0, ExploreSitesSection.compareCategoryPriority(cat1, cat1));
}
}
\ No newline at end of file
...@@ -1088,65 +1088,22 @@ const FeatureEntry::FeatureVariation kTabFreezeVariations[] = { ...@@ -1088,65 +1088,22 @@ const FeatureEntry::FeatureVariation kTabFreezeVariations[] = {
const FeatureEntry::FeatureParam kExploreSitesExperimental = { const FeatureEntry::FeatureParam kExploreSitesExperimental = {
chrome::android::explore_sites::kExploreSitesVariationParameterName, chrome::android::explore_sites::kExploreSitesVariationParameterName,
chrome::android::explore_sites::kExploreSitesVariationExperimental}; chrome::android::explore_sites::kExploreSitesVariationExperimental};
const FeatureEntry::FeatureParam kExploreSitesPersonalized = {
chrome::android::explore_sites::kExploreSitesVariationParameterName,
chrome::android::explore_sites::kExploreSitesVariationPersonalized};
const FeatureEntry::FeatureParam kExploreSitesDenseTitleBottom[] = { const FeatureEntry::FeatureParam kExploreSitesDenseTitleBottom[] = {
{chrome::android::explore_sites::kExploreSitesVariationParameterName,
chrome::android::explore_sites::kExploreSitesVariationMostLikelyTile},
{chrome::android::explore_sites::kExploreSitesDenseVariationParameterName, {chrome::android::explore_sites::kExploreSitesDenseVariationParameterName,
chrome::android::explore_sites:: chrome::android::explore_sites::
kExploreSitesDenseVariationDenseTitleBottom}, kExploreSitesDenseVariationDenseTitleBottom},
{chrome::android::explore_sites:: };
kExploreSitesMostLikelyVariationParameterName,
chrome::android::explore_sites::kExploreSitesMostLikelyVariationIconDots}};
const FeatureEntry::FeatureParam kExploreSitesDenseTitleRight[] = { const FeatureEntry::FeatureParam kExploreSitesDenseTitleRight[] = {
{chrome::android::explore_sites::kExploreSitesVariationParameterName,
chrome::android::explore_sites::kExploreSitesVariationMostLikelyTile},
{chrome::android::explore_sites::kExploreSitesDenseVariationParameterName, {chrome::android::explore_sites::kExploreSitesDenseVariationParameterName,
chrome::android::explore_sites:: chrome::android::explore_sites::
kExploreSitesDenseVariationDenseTitleRight}, kExploreSitesDenseVariationDenseTitleRight},
{chrome::android::explore_sites:: };
kExploreSitesMostLikelyVariationParameterName,
chrome::android::explore_sites::kExploreSitesMostLikelyVariationIconDots}};
const FeatureEntry::FeatureParam kExploreSitesIconArrow[] = {
{chrome::android::explore_sites::kExploreSitesVariationParameterName,
chrome::android::explore_sites::kExploreSitesVariationMostLikelyTile},
{chrome::android::explore_sites::
kExploreSitesMostLikelyVariationParameterName,
chrome::android::explore_sites::
kExploreSitesMostLikelyVariationIconArrow}};
const FeatureEntry::FeatureParam kExploreSitesIconDots[] = {
{chrome::android::explore_sites::kExploreSitesVariationParameterName,
chrome::android::explore_sites::kExploreSitesVariationMostLikelyTile},
{chrome::android::explore_sites::
kExploreSitesMostLikelyVariationParameterName,
chrome::android::explore_sites::kExploreSitesMostLikelyVariationIconDots}};
const FeatureEntry::FeatureParam kExploreSitesIconGrouped[] = {
{chrome::android::explore_sites::kExploreSitesVariationParameterName,
chrome::android::explore_sites::kExploreSitesVariationMostLikelyTile},
{chrome::android::explore_sites::
kExploreSitesMostLikelyVariationParameterName,
chrome::android::explore_sites::
kExploreSitesMostLikelyVariationIconGrouped}};
const FeatureEntry::FeatureParam kExploreSitesWithGamesTop[] = { const FeatureEntry::FeatureParam kExploreSitesWithGamesTop[] = {
{chrome::android::explore_sites::kExploreSitesVariationParameterName,
chrome::android::explore_sites::kExploreSitesVariationMostLikelyTile},
{chrome::android::explore_sites::
kExploreSitesMostLikelyVariationParameterName,
chrome::android::explore_sites::kExploreSitesMostLikelyVariationIconDots},
{chrome::android::explore_sites:: {chrome::android::explore_sites::
kExploreSitesHeadersExperimentParameterName, kExploreSitesHeadersExperimentParameterName,
chrome::android::explore_sites::kExploreSitesGamesTopExperiment}}; chrome::android::explore_sites::kExploreSitesGamesTopExperiment}};
const FeatureEntry::FeatureVariation kExploreSitesVariations[] = { const FeatureEntry::FeatureVariation kExploreSitesVariations[] = {
{"Experimental", &kExploreSitesExperimental, 1, nullptr}, {"Experimental", &kExploreSitesExperimental, 1, nullptr},
{"Personalized", &kExploreSitesPersonalized, 1, nullptr},
{"Arrow Icon", kExploreSitesIconArrow, base::size(kExploreSitesIconArrow),
nullptr},
{"Dots Icon", kExploreSitesIconDots, base::size(kExploreSitesIconDots),
nullptr},
{"Grouped Icon", kExploreSitesIconGrouped,
base::size(kExploreSitesIconGrouped), nullptr},
{"Games Top", kExploreSitesWithGamesTop, {"Games Top", kExploreSitesWithGamesTop,
base::size(kExploreSitesWithGamesTop), nullptr}, base::size(kExploreSitesWithGamesTop), nullptr},
{"Dense Title Bottom", kExploreSitesDenseTitleBottom, {"Dense Title Bottom", kExploreSitesDenseTitleBottom,
......
...@@ -148,40 +148,12 @@ void IgnoreCatalog(GetCatalogStatus status, ...@@ -148,40 +148,12 @@ void IgnoreCatalog(GetCatalogStatus status,
} // namespace } // namespace
// static
void JNI_ExploreSitesBridge_GetEspCatalog(
JNIEnv* env,
const JavaParamRef<jobject>& j_profile,
const JavaParamRef<jobject>& j_result_obj,
const JavaParamRef<jobject>& j_callback_obj) {
Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
DCHECK(profile);
ExploreSitesService* service =
ExploreSitesServiceFactory::GetForBrowserContext(profile);
if (!service) {
DLOG(ERROR) << "Unable to create the ExploreSitesService!";
base::android::RunObjectCallbackAndroid(j_callback_obj, nullptr);
return;
}
service->GetCatalog(
base::BindOnce(&CatalogReady, ScopedJavaGlobalRef<jobject>(j_result_obj),
ScopedJavaGlobalRef<jobject>(j_callback_obj)));
}
// static // static
jint JNI_ExploreSitesBridge_GetVariation(JNIEnv* env) { jint JNI_ExploreSitesBridge_GetVariation(JNIEnv* env) {
return static_cast<jint>( return static_cast<jint>(
chrome::android::explore_sites::GetExploreSitesVariation()); chrome::android::explore_sites::GetExploreSitesVariation());
} }
// static
jint JNI_ExploreSitesBridge_GetIconVariation(JNIEnv* env) {
return static_cast<jint>(
chrome::android::explore_sites::GetMostLikelyVariation());
}
// static // static
jint JNI_ExploreSitesBridge_GetDenseVariation(JNIEnv* env) { jint JNI_ExploreSitesBridge_GetDenseVariation(JNIEnv* env) {
return static_cast<jint>(chrome::android::explore_sites::GetDenseVariation()); return static_cast<jint>(chrome::android::explore_sites::GetDenseVariation());
...@@ -320,22 +292,6 @@ void JNI_ExploreSitesBridge_RecordClick(JNIEnv* env, ...@@ -320,22 +292,6 @@ void JNI_ExploreSitesBridge_RecordClick(JNIEnv* env,
service->RecordClick(url, category_type); service->RecordClick(url, category_type);
} }
void JNI_ExploreSitesBridge_IncrementNtpShownCount(
JNIEnv* env,
const JavaParamRef<jobject>& j_profile,
const jint j_category_id) {
Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
ExploreSitesService* service =
ExploreSitesServiceFactory::GetForBrowserContext(profile);
if (!service) {
DLOG(ERROR) << "Unable to create the ExploreSitesService!";
return;
}
int category_id = static_cast<int>(j_category_id);
service->IncrementNtpShownCount(category_id);
}
// static // static
void ExploreSitesBridge::ScheduleDailyTask() { void ExploreSitesBridge::ScheduleDailyTask() {
JNIEnv* env = base::android::AttachCurrentThread(); JNIEnv* env = base::android::AttachCurrentThread();
...@@ -348,30 +304,6 @@ float ExploreSitesBridge::GetScaleFactorFromDevice() { ...@@ -348,30 +304,6 @@ float ExploreSitesBridge::GetScaleFactorFromDevice() {
return Java_ExploreSitesBridge_getScaleFactorFromDevice(env); return Java_ExploreSitesBridge_getScaleFactorFromDevice(env);
} }
// static
void JNI_ExploreSitesBridge_GetCategoryImage(
JNIEnv* env,
const JavaParamRef<jobject>& j_profile,
const jint j_category_id,
const jint j_pixel_size,
const JavaParamRef<jobject>& j_callback_obj) {
Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
DCHECK(profile);
ExploreSitesService* service =
ExploreSitesServiceFactory::GetForBrowserContext(profile);
if (!service) {
DLOG(ERROR) << "Unable to create the ExploreSitesService!";
base::android::RunBooleanCallbackAndroid(j_callback_obj, false);
return;
}
service->GetCategoryImage(
j_category_id, j_pixel_size,
base::BindOnce(&ImageReady,
ScopedJavaGlobalRef<jobject>(j_callback_obj)));
}
// static // static
void JNI_ExploreSitesBridge_GetSummaryImage( void JNI_ExploreSitesBridge_GetSummaryImage(
JNIEnv* env, JNIEnv* env,
......
...@@ -13,36 +13,22 @@ namespace android { ...@@ -13,36 +13,22 @@ namespace android {
namespace explore_sites { namespace explore_sites {
const char kExploreSitesVariationParameterName[] = "variation"; const char kExploreSitesVariationParameterName[] = "variation";
const char kExploreSitesVariationExperimental[] = "experiment"; const char kExploreSitesVariationExperimental[] = "experiment";
const char kExploreSitesVariationPersonalized[] = "personalized";
const char kExploreSitesVariationMostLikelyTile[] = "mostLikelyTile";
const char kExploreSitesMostLikelyVariationParameterName[] =
"mostLikelyVariation";
const char kExploreSitesHeadersExperimentParameterName[] = "exp"; const char kExploreSitesHeadersExperimentParameterName[] = "exp";
const char kExploreSitesGamesTopExperiment[] = "games-top";
const char kExploreSitesMostLikelyVariationIconArrow[] = "arrowIcon";
const char kExploreSitesMostLikelyVariationIconDots[] = "dotsIcon";
const char kExploreSitesMostLikelyVariationIconGrouped[] = "groupedIcon";
const char kExploreSitesDenseVariationParameterName[] = "denseVariation"; const char kExploreSitesDenseVariationParameterName[] = "denseVariation";
const char kExploreSitesDenseVariationOriginal[] = "original"; const char kExploreSitesDenseVariationOriginal[] = "original";
const char kExploreSitesDenseVariationDenseTitleBottom[] = "titleBottom"; const char kExploreSitesDenseVariationDenseTitleBottom[] = "titleBottom";
const char kExploreSitesDenseVariationDenseTitleRight[] = "titleRight"; const char kExploreSitesDenseVariationDenseTitleRight[] = "titleRight";
const char kExploreSitesGamesTopExperiment[] = "games-top";
ExploreSitesVariation GetExploreSitesVariation() { ExploreSitesVariation GetExploreSitesVariation() {
if (base::FeatureList::IsEnabled(kExploreSites)) { if (base::FeatureList::IsEnabled(kExploreSites)) {
const std::string feature_param = base::GetFieldTrialParamValueByFeature( const std::string feature_param = base::GetFieldTrialParamValueByFeature(
kExploreSites, kExploreSitesVariationParameterName); kExploreSites, kExploreSitesVariationParameterName);
if (feature_param == kExploreSitesVariationExperimental) { if (feature_param == kExploreSitesVariationExperimental) {
return ExploreSitesVariation::EXPERIMENT; return ExploreSitesVariation::EXPERIMENT;
} else if (feature_param == kExploreSitesVariationPersonalized) {
return ExploreSitesVariation::PERSONALIZED;
} else if (feature_param == kExploreSitesVariationMostLikelyTile) {
return ExploreSitesVariation::MOST_LIKELY;
} else { } else {
return ExploreSitesVariation::ENABLED; return ExploreSitesVariation::ENABLED;
} }
...@@ -50,30 +36,6 @@ ExploreSitesVariation GetExploreSitesVariation() { ...@@ -50,30 +36,6 @@ ExploreSitesVariation GetExploreSitesVariation() {
return ExploreSitesVariation::DISABLED; return ExploreSitesVariation::DISABLED;
} }
MostLikelyVariation GetMostLikelyVariation() {
if (base::FeatureList::IsEnabled(kExploreSites) &&
base::GetFieldTrialParamValueByFeature(
kExploreSites, kExploreSitesVariationParameterName) ==
kExploreSitesVariationMostLikelyTile) {
if (base::GetFieldTrialParamValueByFeature(
kExploreSites, kExploreSitesMostLikelyVariationParameterName) ==
kExploreSitesMostLikelyVariationIconArrow) {
return MostLikelyVariation::ICON_ARROW;
}
if (base::GetFieldTrialParamValueByFeature(
kExploreSites, kExploreSitesMostLikelyVariationParameterName) ==
kExploreSitesMostLikelyVariationIconDots) {
return MostLikelyVariation::ICON_DOTS;
}
if (base::GetFieldTrialParamValueByFeature(
kExploreSites, kExploreSitesMostLikelyVariationParameterName) ==
kExploreSitesMostLikelyVariationIconGrouped) {
return MostLikelyVariation::ICON_GROUPED;
}
}
return MostLikelyVariation::NONE;
}
DenseVariation GetDenseVariation() { DenseVariation GetDenseVariation() {
if (base::GetFieldTrialParamValueByFeature( if (base::GetFieldTrialParamValueByFeature(
kExploreSites, kExploreSitesDenseVariationParameterName) == kExploreSites, kExploreSitesDenseVariationParameterName) ==
......
...@@ -10,47 +10,30 @@ namespace android { ...@@ -10,47 +10,30 @@ namespace android {
namespace explore_sites { namespace explore_sites {
extern const char kExploreSitesVariationParameterName[]; extern const char kExploreSitesVariationParameterName[];
extern const char kExploreSitesVariationExperimental[]; extern const char kExploreSitesVariationExperimental[];
extern const char kExploreSitesVariationPersonalized[];
extern const char kExploreSitesVariationMostLikelyTile[];
extern const char kExploreSitesMostLikelyVariationParameterName[];
extern const char kExploreSitesHeadersExperimentParameterName[]; extern const char kExploreSitesHeadersExperimentParameterName[];
extern const char kExploreSitesGamesTopExperiment[];
extern const char kExploreSitesMostLikelyVariationIconArrow[];
extern const char kExploreSitesMostLikelyVariationIconDots[];
extern const char kExploreSitesMostLikelyVariationIconGrouped[];
extern const char kExploreSitesDenseVariationParameterName[]; extern const char kExploreSitesDenseVariationParameterName[];
extern const char kExploreSitesDenseVariationOriginal[]; extern const char kExploreSitesDenseVariationOriginal[];
extern const char kExploreSitesDenseVariationDenseTitleBottom[]; extern const char kExploreSitesDenseVariationDenseTitleBottom[];
extern const char kExploreSitesDenseVariationDenseTitleRight[]; extern const char kExploreSitesDenseVariationDenseTitleRight[];
extern const char kExploreSitesGamesTopExperiment[];
// A Java counterpart will be generated for this enum. // A Java counterpart will be generated for this enum.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.explore_sites // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.explore_sites
enum class ExploreSitesVariation { enum class ExploreSitesVariation {
ENABLED, ENABLED,
EXPERIMENT, EXPERIMENT,
PERSONALIZED,
MOST_LIKELY,
DISABLED DISABLED
}; };
// A Java counterpart will be generated for this enum.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.explore_sites
enum class MostLikelyVariation { NONE, ICON_ARROW, ICON_DOTS, ICON_GROUPED };
// A Java counterpart will be generated for this enum. // A Java counterpart will be generated for this enum.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.explore_sites // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.explore_sites
enum class DenseVariation { ORIGINAL, DENSE_TITLE_BOTTOM, DENSE_TITLE_RIGHT }; enum class DenseVariation { ORIGINAL, DENSE_TITLE_BOTTOM, DENSE_TITLE_RIGHT };
ExploreSitesVariation GetExploreSitesVariation(); ExploreSitesVariation GetExploreSitesVariation();
MostLikelyVariation GetMostLikelyVariation();
DenseVariation GetDenseVariation(); DenseVariation GetDenseVariation();
} // namespace explore_sites } // namespace explore_sites
......
...@@ -64,45 +64,6 @@ TEST(ExploreSitesFeatureTest, ExploreSitesDenseVariationOriginal) { ...@@ -64,45 +64,6 @@ TEST(ExploreSitesFeatureTest, ExploreSitesDenseVariationOriginal) {
EXPECT_EQ(DenseVariation::ORIGINAL, GetDenseVariation()); EXPECT_EQ(DenseVariation::ORIGINAL, GetDenseVariation());
} }
TEST(ExploreSitesFeatureTest, ExploreSitesEnabledWithIconArrow) {
std::map<std::string, std::string> parameters;
parameters[kExploreSitesVariationParameterName] =
kExploreSitesVariationMostLikelyTile;
parameters[kExploreSitesMostLikelyVariationParameterName] =
kExploreSitesMostLikelyVariationIconArrow;
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeatureWithParameters(kExploreSites,
parameters);
EXPECT_EQ(ExploreSitesVariation::MOST_LIKELY, GetExploreSitesVariation());
EXPECT_EQ(MostLikelyVariation::ICON_ARROW, GetMostLikelyVariation());
}
TEST(ExploreSitesFeatureTest, ExploreSitesEnabledWithIconDots) {
std::map<std::string, std::string> parameters;
parameters[kExploreSitesVariationParameterName] =
kExploreSitesVariationMostLikelyTile;
parameters[kExploreSitesMostLikelyVariationParameterName] =
kExploreSitesMostLikelyVariationIconDots;
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeatureWithParameters(kExploreSites,
parameters);
EXPECT_EQ(ExploreSitesVariation::MOST_LIKELY, GetExploreSitesVariation());
EXPECT_EQ(MostLikelyVariation::ICON_DOTS, GetMostLikelyVariation());
}
TEST(ExploreSitesFeatureTest, ExploreSitesEnabledWithIconGrouped) {
std::map<std::string, std::string> parameters;
parameters[kExploreSitesVariationParameterName] =
kExploreSitesVariationMostLikelyTile;
parameters[kExploreSitesMostLikelyVariationParameterName] =
kExploreSitesMostLikelyVariationIconGrouped;
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeatureWithParameters(kExploreSites,
parameters);
EXPECT_EQ(ExploreSitesVariation::MOST_LIKELY, GetExploreSitesVariation());
EXPECT_EQ(MostLikelyVariation::ICON_GROUPED, GetMostLikelyVariation());
}
TEST(ExploreSitesFeatureTest, ExploreSitesEnabledWithBogus) { TEST(ExploreSitesFeatureTest, ExploreSitesEnabledWithBogus) {
const char bogusParamValue[] = "bogus"; const char bogusParamValue[] = "bogus";
std::map<std::string, std::string> parameters; std::map<std::string, std::string> parameters;
......
...@@ -20,14 +20,6 @@ class ExploreSitesService : public KeyedService { ...@@ -20,14 +20,6 @@ class ExploreSitesService : public KeyedService {
// Returns via callback the current catalog stored locally. // Returns via callback the current catalog stored locally.
virtual void GetCatalog(CatalogCallback callback) = 0; virtual void GetCatalog(CatalogCallback callback) = 0;
// Returns via callback the image for a category. This image is composed from
// multiple site images. The site images are checked against the user
// blacklist so that unwanted sites are not represented in the category image.
// Returns |nullptr| if there was an error, or no match.
virtual void GetCategoryImage(int category_id,
int pixel_size,
BitmapCallback callback) = 0;
// Returns via callback an image representing a summary of the current // Returns via callback an image representing a summary of the current
// catalog. This image is composed from multiple site images. // catalog. This image is composed from multiple site images.
// Returns |nullptr| if there was an error. // Returns |nullptr| if there was an error.
...@@ -57,10 +49,6 @@ class ExploreSitesService : public KeyedService { ...@@ -57,10 +49,6 @@ class ExploreSitesService : public KeyedService {
base::Time end, base::Time end,
base::OnceClosure callback) = 0; base::OnceClosure callback) = 0;
// Increment the ntp_shown_count for the particular category.
// |category_id| the row id of the category to increment.
virtual void IncrementNtpShownCount(int category_id) = 0;
// Controls for use by chrome://explore-sites-internals. // Controls for use by chrome://explore-sites-internals.
virtual void ClearCachedCatalogsForDebugging() = 0; virtual void ClearCachedCatalogsForDebugging() = 0;
virtual void OverrideCountryCodeForDebugging( virtual void OverrideCountryCodeForDebugging(
......
...@@ -69,10 +69,7 @@ ExploreSitesServiceImpl::~ExploreSitesServiceImpl() {} ...@@ -69,10 +69,7 @@ ExploreSitesServiceImpl::~ExploreSitesServiceImpl() {}
// static // static
bool ExploreSitesServiceImpl::IsExploreSitesEnabled() { bool ExploreSitesServiceImpl::IsExploreSitesEnabled() {
ExploreSitesVariation variation = GetExploreSitesVariation(); return GetExploreSitesVariation() == ExploreSitesVariation::ENABLED;
return variation == ExploreSitesVariation::ENABLED ||
variation == ExploreSitesVariation::PERSONALIZED ||
variation == ExploreSitesVariation::MOST_LIKELY;
} }
void ExploreSitesServiceImpl::GetCatalog(CatalogCallback callback) { void ExploreSitesServiceImpl::GetCatalog(CatalogCallback callback) {
...@@ -86,16 +83,6 @@ void ExploreSitesServiceImpl::GetCatalog(CatalogCallback callback) { ...@@ -86,16 +83,6 @@ void ExploreSitesServiceImpl::GetCatalog(CatalogCallback callback) {
std::move(callback))); std::move(callback)));
} }
void ExploreSitesServiceImpl::GetCategoryImage(int category_id,
int pixel_size,
BitmapCallback callback) {
task_queue_.AddTask(std::make_unique<GetImagesTask>(
explore_sites_store_.get(), category_id, kFaviconsPerCategoryImage,
base::BindOnce(&ExploreSitesServiceImpl::ComposeCategoryImage,
weak_ptr_factory_.GetWeakPtr(), std::move(callback),
pixel_size)));
}
void ExploreSitesServiceImpl::GetSummaryImage(int pixel_size, void ExploreSitesServiceImpl::GetSummaryImage(int pixel_size,
BitmapCallback callback) { BitmapCallback callback) {
task_queue_.AddTask(std::make_unique<GetImagesTask>( task_queue_.AddTask(std::make_unique<GetImagesTask>(
...@@ -166,11 +153,6 @@ void ExploreSitesServiceImpl::ClearActivities(base::Time begin, ...@@ -166,11 +153,6 @@ void ExploreSitesServiceImpl::ClearActivities(base::Time begin,
std::move(callback)))); std::move(callback))));
} }
void ExploreSitesServiceImpl::IncrementNtpShownCount(int category_id) {
task_queue_.AddTask(std::make_unique<IncrementShownCountTask>(
explore_sites_store_.get(), category_id));
}
void ExploreSitesServiceImpl::ClearCachedCatalogsForDebugging() { void ExploreSitesServiceImpl::ClearCachedCatalogsForDebugging() {
task_queue_.AddTask(std::make_unique<ClearCatalogTask>( task_queue_.AddTask(std::make_unique<ClearCatalogTask>(
explore_sites_store_.get(), base::BindOnce([](bool result) {}))); explore_sites_store_.get(), base::BindOnce([](bool result) {})));
......
...@@ -43,9 +43,6 @@ class ExploreSitesServiceImpl : public ExploreSitesService, ...@@ -43,9 +43,6 @@ class ExploreSitesServiceImpl : public ExploreSitesService,
// ExploreSitesService implementation. // ExploreSitesService implementation.
void GetCatalog(CatalogCallback callback) override; void GetCatalog(CatalogCallback callback) override;
void GetCategoryImage(int category_id,
int pixel_size,
BitmapCallback callback) override;
void GetSummaryImage(int pixel_size, BitmapCallback callback) override; void GetSummaryImage(int pixel_size, BitmapCallback callback) override;
void GetSiteImage(int site_id, BitmapCallback callback) override; void GetSiteImage(int site_id, BitmapCallback callback) override;
void UpdateCatalogFromNetwork(bool is_immediate_fetch, void UpdateCatalogFromNetwork(bool is_immediate_fetch,
...@@ -56,7 +53,6 @@ class ExploreSitesServiceImpl : public ExploreSitesService, ...@@ -56,7 +53,6 @@ class ExploreSitesServiceImpl : public ExploreSitesService,
void ClearActivities(base::Time begin, void ClearActivities(base::Time begin,
base::Time end, base::Time end,
base::OnceClosure callback) override; base::OnceClosure callback) override;
void IncrementNtpShownCount(int category_id) override;
void ClearCachedCatalogsForDebugging() override; void ClearCachedCatalogsForDebugging() override;
void OverrideCountryCodeForDebugging( void OverrideCountryCodeForDebugging(
const std::string& country_code) override; const std::string& country_code) override;
......
...@@ -11,13 +11,8 @@ ...@@ -11,13 +11,8 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
namespace explore_sites { namespace explore_sites {
using chrome::android::explore_sites::GetMostLikelyVariation;
using chrome::android::explore_sites::MostLikelyVariation;
std::unique_ptr<MostVisitedClient> MostVisitedClient::Create() { std::unique_ptr<MostVisitedClient> MostVisitedClient::Create() {
if (GetMostLikelyVariation() == MostLikelyVariation::NONE)
return nullptr;
// note: wrap_unique is used because the constructor is private. // note: wrap_unique is used because the constructor is private.
return base::WrapUnique(new MostVisitedClient()); return base::WrapUnique(new MostVisitedClient());
} }
......
...@@ -2703,15 +2703,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p ...@@ -2703,15 +2703,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_NTP_EXPLORE_SITES_MORE" desc="Text on a button leading to a complete view of all categories for all popular websites"> <message name="IDS_NTP_EXPLORE_SITES_MORE" desc="Text on a button leading to a complete view of all categories for all popular websites">
More categories More categories
</message> </message>
<message name="IDS_EXPLORE_SITES_DEFAULT_CATEGORY_NEWS" desc="The caption for a button that when clicked opens a UI in this tab that shows a list of websites with content related to news. [CHAR-LIMIT=12]">
News
</message>
<message name="IDS_EXPLORE_SITES_DEFAULT_CATEGORY_SPORTS" desc="The caption for a button that when clicked opens a UI in this tab that shows a list of websites with content related to sports. For example, soccer, cricket, football, running [CHAR-LIMIT=12]">
Sports
</message>
<message name="IDS_EXPLORE_SITES_DEFAULT_CATEGORY_SHOPPING" desc="The caption for a button that when clicked opens a UI in this tab that shows a list of websites with content related to shopping. [CHAR-LIMIT=12]">
Shopping
</message>
<message name="IDS_EXPLORE_SITES_LOADING_FROM_NET" desc="Caption for an indeterminate loading spinner indicating that we are loading the data from the internet"> <message name="IDS_EXPLORE_SITES_LOADING_FROM_NET" desc="Caption for an indeterminate loading spinner indicating that we are loading the data from the internet">
Finding the best from the web… Finding the best from the web…
</message> </message>
...@@ -2727,9 +2718,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p ...@@ -2727,9 +2718,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_EXPLORE_SITES_LOADING_ERROR_NEXT_STEPS_CHECK_CONNECTION" desc="Text on an error screen indicating that checking network connection can fix this error."> <message name="IDS_EXPLORE_SITES_LOADING_ERROR_NEXT_STEPS_CHECK_CONNECTION" desc="Text on an error screen indicating that checking network connection can fix this error.">
Checking your internet connection Checking your internet connection
</message> </message>
<message name="IDS_EXPLORE_SITES_TOP_SITES_TILE" desc="A label for a button that when clicked takes the user to a tab that contains categorized links to websites that are popular in their country. [CHAR_LIMIT=12]">
Top sites
</message>
<message name="IDS_EXPLORE_SITES_IPH" desc="An in-product-help message for the explore sites feature on Android. The message encourages users to open a tab that contains categorized links to websites that are popular in their country."> <message name="IDS_EXPLORE_SITES_IPH" desc="An in-product-help message for the explore sites feature on Android. The message encourages users to open a tab that contains categorized links to websites that are popular in their country.">
See popular websites See popular websites
</message> </message>
......
...@@ -30,10 +30,6 @@ std::string GetChromeFlagsSetupString() { ...@@ -30,10 +30,6 @@ std::string GetChromeFlagsSetupString() {
return "Enabled"; return "Enabled";
case ExploreSitesVariation::EXPERIMENT: case ExploreSitesVariation::EXPERIMENT:
return "Experiment"; return "Experiment";
case ExploreSitesVariation::PERSONALIZED:
return "Personalized";
case ExploreSitesVariation::MOST_LIKELY:
return "Most Likely";
case ExploreSitesVariation::DISABLED: case ExploreSitesVariation::DISABLED:
return "Disabled"; return "Disabled";
} }
......
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