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 org.chromium.base.Callback; |
| 8 import org.chromium.chrome.browser.favicon.FaviconHelper.FaviconImageCallback; |
| 9 import org.chromium.chrome.browser.favicon.FaviconHelper.IconAvailabilityCallbac
k; |
| 10 import org.chromium.chrome.browser.favicon.LargeIconBridge.LargeIconCallback; |
| 11 import org.chromium.chrome.browser.ntp.NewTabPage.DestructionObserver; |
| 12 import org.chromium.chrome.browser.ntp.snippets.SuggestionsSource; |
| 13 |
| 14 import java.util.Set; |
| 15 |
| 16 /** |
| 17 * Interface between the suggestion surface and the rest of the browser. |
| 18 */ |
| 19 public interface SuggestionsUiDelegate { |
| 20 // Dependency injection |
| 21 // TODO(dgn): remove these methods once the users have a different way to ge
t a reference |
| 22 // to these objects (https://crbug.com/677672) |
| 23 |
| 24 /** Convenience method to access the {@link SuggestionsSource}. */ |
| 25 SuggestionsSource getSuggestionsSource(); |
| 26 |
| 27 /** Convenience method to access the {@link SuggestionsMetricsReporter}. */ |
| 28 SuggestionsMetricsReporter getMetricsReporter(); |
| 29 |
| 30 /** Convenience method to access the {@link SuggestionsNavigationDelegate}.
*/ |
| 31 SuggestionsNavigationDelegate getNavigationDelegate(); |
| 32 |
| 33 // Favicons |
| 34 |
| 35 /** |
| 36 * Checks if an icon with the given URL is available. If not, |
| 37 * downloads it and stores it as a favicon/large icon for the given {@code p
ageUrl}. |
| 38 * @param pageUrl The URL of the site whose icon is being requested. |
| 39 * @param iconUrl The URL of the favicon/large icon. |
| 40 * @param isLargeIcon Whether the {@code iconUrl} represents a large icon or
favicon. |
| 41 * @param callback The callback to be notified when the favicon has been che
cked. |
| 42 */ |
| 43 void ensureIconIsAvailable(String pageUrl, String iconUrl, boolean isLargeIc
on, |
| 44 boolean isTemporary, IconAvailabilityCallback callback); |
| 45 |
| 46 /** |
| 47 * Gets the large icon (e.g. favicon or touch icon) for a given URL. |
| 48 * @param url The URL of the site whose icon is being requested. |
| 49 * @param size The desired size of the icon in pixels. |
| 50 * @param callback The callback to be notified when the icon is available. |
| 51 */ |
| 52 void getLargeIconForUrl(String url, int size, LargeIconCallback callback); |
| 53 |
| 54 /** |
| 55 * Gets the favicon image for a given URL. |
| 56 * @param url The URL of the site whose favicon is being requested. |
| 57 * @param size The desired size of the favicon in pixels. |
| 58 * @param faviconCallback The callback to be notified when the favicon is av
ailable. |
| 59 */ |
| 60 void getLocalFaviconImageForURL(String url, int size, FaviconImageCallback f
aviconCallback); |
| 61 |
| 62 // Feature/State checks |
| 63 |
| 64 /** |
| 65 * Registers a {@link DestructionObserver}, notified when the New Tab Page g
oes away. |
| 66 */ |
| 67 void addDestructionObserver(DestructionObserver destructionObserver); |
| 68 |
| 69 // Offline |
| 70 |
| 71 /** |
| 72 * Checks if the pages with the given URLs are available offline. |
| 73 * @param pageUrls The URLs of the sites whose offline availability is reque
sted. |
| 74 * @param callback Fired when the results are available. |
| 75 */ |
| 76 void getUrlsAvailableOffline(Set<String> pageUrls, Callback<Set<String>> cal
lback); |
| 77 } |
OLD | NEW |