Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4338)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java

Issue 2623993007: 🏠 Extract the ContentSuggestionManager interface from NTP (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
index 78ff652057e3d5222af99540591947c2e8f2ca92..7a5b0a59adb4c671243dfc7eedc0d39013f77cb7 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
@@ -42,8 +42,6 @@
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
-import org.chromium.chrome.browser.favicon.FaviconHelper.FaviconImageCallback;
-import org.chromium.chrome.browser.favicon.FaviconHelper.IconAvailabilityCallback;
import org.chromium.chrome.browser.favicon.LargeIconBridge.LargeIconCallback;
import org.chromium.chrome.browser.ntp.LogoBridge.Logo;
import org.chromium.chrome.browser.ntp.LogoBridge.LogoObserver;
@@ -53,12 +51,11 @@
import org.chromium.chrome.browser.ntp.cards.CardsVariationParameters;
import org.chromium.chrome.browser.ntp.cards.NewTabPageAdapter;
import org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView;
-import org.chromium.chrome.browser.ntp.snippets.SnippetArticle;
import org.chromium.chrome.browser.ntp.snippets.SnippetsConfig;
-import org.chromium.chrome.browser.ntp.snippets.SuggestionsSource;
import org.chromium.chrome.browser.offlinepages.OfflinePageBridge;
import org.chromium.chrome.browser.profiles.MostVisitedSites.MostVisitedURLsObserver;
import org.chromium.chrome.browser.profiles.Profile;
+import org.chromium.chrome.browser.suggestions.ContentSuggestionsManager;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.util.MathUtils;
import org.chromium.chrome.browser.util.ViewUtils;
@@ -138,7 +135,7 @@
/**
* Manages the view interaction with the rest of the system.
*/
- public interface NewTabPageManager extends MostVisitedItemManager {
+ public interface NewTabPageManager extends MostVisitedItemManager, ContentSuggestionsManager {
/** @return Whether the location bar is shown in the NTP. */
boolean isLocationBarShownInNTP();
@@ -148,61 +145,6 @@
/** @return Whether the omnibox 'Search or type URL' text should be shown. */
boolean isFakeOmniboxTextEnabledTablet();
- /** @return Whether context menus should allow the option to open a link in a new window. */
- boolean isOpenInNewWindowEnabled();
-
- /** @return Whether context menus should allow the option to open a link in incognito. */
- boolean isOpenInIncognitoEnabled();
-
- /** Opens the bookmarks page in the current tab. */
- void navigateToBookmarks();
-
- /** Opens the recent tabs page in the current tab. */
- void navigateToRecentTabs();
-
- /** Opens the Download Manager UI in the current tab. */
- void navigateToDownloadManager();
-
- /**
- * Tracks per-page-load metrics for content suggestions.
- * @param categories The categories of content suggestions.
- * @param suggestionsPerCategory The number of content suggestions in each category.
- */
- void trackSnippetsPageImpression(int[] categories, int[] suggestionsPerCategory);
-
- /**
- * Tracks impression metrics for a content suggestion.
- * @param article The content suggestion that was shown to the user.
- */
- void trackSnippetImpression(SnippetArticle article);
-
- /**
- * Tracks impression metrics for the long-press menu for a content suggestion.
- * @param article The content suggestion for which the long-press menu was opened.
- */
- void trackSnippetMenuOpened(SnippetArticle article);
-
- /**
- * Tracks impression metrics for a category's action button ("More").
- * @param category The category for which the action button was shown.
- * @param position The position of the action button within the category.
- */
- void trackSnippetCategoryActionImpression(int category, int position);
-
- /**
- * Tracks click metrics for a category's action button ("More").
- * @param category The category for which the action button was clicked.
- * @param position The position of the action button within the category.
- */
- void trackSnippetCategoryActionClick(int category, int position);
-
- /**
- * Opens a content suggestion and records related metrics.
- * @param windowOpenDisposition How to open (current tab, new tab, new window etc).
- * @param article The content suggestion to open.
- */
- void openSnippet(int windowOpenDisposition, SnippetArticle article);
-
/**
* Animates the search box up into the omnibox and bring up the keyboard.
* @param beginVoiceSearch Whether to begin a voice search.
@@ -218,41 +160,6 @@
void setMostVisitedURLsObserver(MostVisitedURLsObserver observer, int numResults);
/**
- * Gets the favicon image for a given URL.
- * @param url The URL of the site whose favicon is being requested.
- * @param size The desired size of the favicon in pixels.
- * @param faviconCallback The callback to be notified when the favicon is available.
- */
- void getLocalFaviconImageForURL(
- String url, int size, FaviconImageCallback faviconCallback);
-
- /**
- * Gets the large icon (e.g. favicon or touch icon) for a given URL.
- * @param url The URL of the site whose icon is being requested.
- * @param size The desired size of the icon in pixels.
- * @param callback The callback to be notified when the icon is available.
- */
- void getLargeIconForUrl(String url, int size, LargeIconCallback callback);
-
- /**
- * Checks if an icon with the given URL is available. If not,
- * downloads it and stores it as a favicon/large icon for the given {@code pageUrl}.
- * @param pageUrl The URL of the site whose icon is being requested.
- * @param iconUrl The URL of the favicon/large icon.
- * @param isLargeIcon Whether the {@code iconUrl} represents a large icon or favicon.
- * @param callback The callback to be notified when the favicon has been checked.
- */
- void ensureIconIsAvailable(String pageUrl, String iconUrl, boolean isLargeIcon,
- boolean isTemporary, IconAvailabilityCallback callback);
-
- /**
- * Checks if the pages with the given URLs are available offline.
- * @param pageUrls The URLs of the sites whose offline availability is requested.
- * @param callback Fired when the results are available.
- */
- void getUrlsAvailableOffline(Set<String> pageUrls, Callback<Set<String>> callback);
-
- /**
* Called when the user clicks on the logo.
* @param isAnimatedLogoShowing Whether the animated GIF logo is playing.
*/
@@ -272,23 +179,6 @@ void ensureIconIsAvailable(String pageUrl, String iconUrl, boolean isLargeIcon,
void onLoadingComplete(MostVisitedItem[] mostVisitedItems);
/**
- * Handles clicks on the "learn more" link in the footer.
- */
- void onLearnMoreClicked();
-
- /**
- * Returns the SuggestionsSource or null if it doesn't exist. The SuggestionsSource is
- * invalidated (has destroy() called) when the NewTabPage is destroyed so use this method
- * instead of keeping your own reference.
- */
- @Nullable SuggestionsSource getSuggestionsSource();
-
- /**
- * Registers a {@link DestructionObserver}, notified when the New Tab Page goes away.
- */
- void addDestructionObserver(DestructionObserver destructionObserver);
-
- /**
* @return whether the {@link NewTabPage} associated with this manager is the current page
* displayed to the user.
*/
@@ -395,7 +285,8 @@ public void onDestroy() {
// Set up snippets
if (mUseCardsUi) {
mNewTabPageAdapter = new NewTabPageAdapter(mManager, mNewTabPageLayout, mUiConfig,
- OfflinePageBridge.getForProfile(Profile.getLastUsedProfile()));
+ OfflinePageBridge.getForProfile(Profile.getLastUsedProfile()),
+ mContextMenuManager);
mRecyclerView.setAdapter(mNewTabPageAdapter);
int scrollOffset;

Powered by Google App Engine
This is Rietveld 408576698