Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.chrome.browser.suggestions; | |
| 6 | |
| 7 import android.support.annotation.Nullable; | |
| 8 | |
| 9 import org.chromium.base.Callback; | |
| 10 import org.chromium.chrome.browser.favicon.FaviconHelper.FaviconImageCallback; | |
| 11 import org.chromium.chrome.browser.favicon.FaviconHelper.IconAvailabilityCallbac k; | |
| 12 import org.chromium.chrome.browser.favicon.LargeIconBridge.LargeIconCallback; | |
| 13 import org.chromium.chrome.browser.ntp.NewTabPage.DestructionObserver; | |
| 14 import org.chromium.chrome.browser.ntp.snippets.SnippetArticle; | |
| 15 import org.chromium.chrome.browser.ntp.snippets.SuggestionsSource; | |
| 16 import org.chromium.content_public.browser.LoadUrlParams; | |
| 17 | |
| 18 import java.util.Set; | |
| 19 | |
| 20 /** | |
| 21 * Interface between the suggestion surface and the rest of the browser. | |
| 22 */ | |
| 23 public interface ContentSuggestionsManager { | |
|
tschumann
2017/01/13 09:05:54
drive-by: I have the feeling we're putting too muc
Bernhard Bauer
2017/01/13 09:30:23
I think this is mostly because of the confusing na
tschumann
2017/01/13 09:38:37
A different name would certainly help. If all clie
| |
| 24 // Dependency injection | |
| 25 | |
| 26 /** | |
| 27 * Returns the SuggestionsSource or null if it doesn't exist. The Suggestion sSource is | |
| 28 * invalidated (has destroy() called) when the NewTabPage is destroyed so us e this method | |
| 29 * instead of keeping your own reference. | |
| 30 */ | |
| 31 @Nullable | |
| 32 SuggestionsSource getSuggestionsSource(); | |
| 33 | |
| 34 // Favicons | |
| 35 | |
| 36 /** | |
| 37 * Checks if an icon with the given URL is available. If not, | |
| 38 * downloads it and stores it as a favicon/large icon for the given {@code p ageUrl}. | |
| 39 * @param pageUrl The URL of the site whose icon is being requested. | |
| 40 * @param iconUrl The URL of the favicon/large icon. | |
| 41 * @param isLargeIcon Whether the {@code iconUrl} represents a large icon or favicon. | |
| 42 * @param callback The callback to be notified when the favicon has been che cked. | |
| 43 */ | |
| 44 void ensureIconIsAvailable(String pageUrl, String iconUrl, boolean isLargeIc on, | |
| 45 boolean isTemporary, IconAvailabilityCallback callback); | |
| 46 | |
| 47 /** | |
| 48 * Gets the large icon (e.g. favicon or touch icon) for a given URL. | |
| 49 * @param url The URL of the site whose icon is being requested. | |
| 50 * @param size The desired size of the icon in pixels. | |
| 51 * @param callback The callback to be notified when the icon is available. | |
| 52 */ | |
| 53 void getLargeIconForUrl(String url, int size, LargeIconCallback callback); | |
| 54 | |
| 55 /** | |
| 56 * Gets the favicon image for a given URL. | |
| 57 * @param url The URL of the site whose favicon is being requested. | |
| 58 * @param size The desired size of the favicon in pixels. | |
| 59 * @param faviconCallback The callback to be notified when the favicon is av ailable. | |
| 60 */ | |
| 61 void getLocalFaviconImageForURL(String url, int size, FaviconImageCallback f aviconCallback); | |
| 62 | |
| 63 // Feature/State checks | |
| 64 | |
| 65 /** @return Whether context menus should allow the option to open a link in incognito. */ | |
| 66 boolean isOpenInIncognitoEnabled(); | |
| 67 | |
| 68 /** @return Whether context menus should allow the option to open a link in a new window. */ | |
| 69 boolean isOpenInNewWindowEnabled(); | |
| 70 | |
| 71 /** | |
| 72 * Registers a {@link DestructionObserver}, notified when the New Tab Page g oes away. | |
| 73 */ | |
| 74 void addDestructionObserver(DestructionObserver destructionObserver); | |
| 75 | |
| 76 // Navigation | |
| 77 | |
| 78 /** Opens the bookmarks page in the current tab. */ | |
| 79 void navigateToBookmarks(); | |
| 80 | |
| 81 /** Opens the Download Manager UI in the current tab. */ | |
| 82 void navigateToDownloadManager(); | |
| 83 | |
| 84 /** Opens the recent tabs page in the current tab. */ | |
| 85 void navigateToRecentTabs(); | |
| 86 | |
| 87 /** | |
| 88 * Handles clicks on the "learn more" link in the footer. | |
| 89 */ | |
| 90 void onLearnMoreClicked(); | |
| 91 | |
| 92 /** | |
| 93 * Opens a content suggestion and records related metrics. | |
| 94 * @param windowOpenDisposition How to open (current tab, new tab, new windo w etc). | |
| 95 * @param article The content suggestion to open. | |
| 96 */ | |
| 97 void openSnippet(int windowOpenDisposition, SnippetArticle article); | |
| 98 | |
| 99 /** Opens an url with the desired disposition. */ | |
| 100 void openUrl(int windowOpenDisposition, LoadUrlParams loadUrlParams); | |
| 101 | |
| 102 // Offline | |
| 103 | |
| 104 /** | |
| 105 * Checks if the pages with the given URLs are available offline. | |
| 106 * @param pageUrls The URLs of the sites whose offline availability is reque sted. | |
| 107 * @param callback Fired when the results are available. | |
| 108 */ | |
| 109 void getUrlsAvailableOffline(Set<String> pageUrls, Callback<Set<String>> cal lback); | |
| 110 | |
| 111 // UMA | |
| 112 | |
| 113 /** | |
| 114 * Tracks per-page-load metrics for content suggestions. | |
| 115 * @param categories The categories of content suggestions. | |
| 116 * @param suggestionsPerCategory The number of content suggestions in each c ategory. | |
| 117 */ | |
| 118 void trackSnippetsPageImpression(int[] categories, int[] suggestionsPerCateg ory); | |
| 119 | |
| 120 /** | |
| 121 * Tracks impression metrics for a content suggestion. | |
| 122 * @param article The content suggestion that was shown to the user. | |
| 123 */ | |
| 124 void trackSnippetImpression(SnippetArticle article); | |
| 125 | |
| 126 /** | |
| 127 * Tracks impression metrics for the long-press menu for a content suggestio n. | |
| 128 * @param article The content suggestion for which the long-press menu was o pened. | |
| 129 */ | |
| 130 void trackSnippetMenuOpened(SnippetArticle article); | |
| 131 | |
| 132 /** | |
| 133 * Tracks impression metrics for a category's action button ("More"). | |
| 134 * @param category The category for which the action button was shown. | |
| 135 * @param position The position of the action button within the category. | |
| 136 */ | |
| 137 void trackSnippetCategoryActionImpression(int category, int position); | |
| 138 | |
| 139 /** | |
| 140 * Tracks click metrics for a category's action button ("More"). | |
| 141 * @param category The category for which the action button was clicked. | |
| 142 * @param position The position of the action button within the category. | |
| 143 */ | |
| 144 void trackSnippetCategoryActionClick(int category, int position); | |
| 145 } | |
| OLD | NEW |