Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java |
| index 936279dd595f5887c23ef20d07d17be46255304f..9bf5f3791ba8094ba8befc34e73b89758d2fde83 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java |
| @@ -38,6 +38,7 @@ import org.chromium.chrome.browser.webapps.WebappDataStorage; |
| import org.chromium.chrome.browser.webapps.WebappLauncherActivity; |
| import org.chromium.chrome.browser.webapps.WebappRegistry; |
| import org.chromium.chrome.browser.widget.RoundedIconGenerator; |
| +import org.chromium.content_public.browser.WebContents; |
| import org.chromium.content_public.common.ScreenOrientationConstants; |
| import org.chromium.ui.widget.Toast; |
| import org.chromium.webapk.lib.client.WebApkValidator; |
| @@ -99,6 +100,14 @@ public class ShortcutHelper { |
| private static final float GENERATED_ICON_PADDING_RATIO = 1.0f / 12.0f; |
| private static final float GENERATED_ICON_FONT_SIZE_RATIO = 1.0f / 3.0f; |
| + /** |
| + * Callback to {@link fetchHomescreenImage()}. Called once the homescreen image has been |
| + * fetched. |
| + */ |
| + public interface FetchHomescreenImageCallback { |
| + public void onFetchedHomescreenImage(Bitmap bitmap, long murmur2Hash); |
| + } |
| + |
| /** Broadcasts Intents out Android for adding the shortcut. */ |
| public static class Delegate { |
| /** |
| @@ -419,6 +428,24 @@ public class ShortcutHelper { |
| } |
| /** |
| + * Fetches the image at {@link iconUrl} and scales it so that it can be used on the homescreen. |
|
dominickn
2016/08/15 05:27:34
This comment is confusing - does nativeFetchHomesc
|
| + */ |
| + public static void fetchHomescreenImage( |
| + WebContents webContents, String imageUrl, FetchHomescreenImageCallback callback) { |
| + nativeFetchHomescreenImage(webContents, imageUrl, callback); |
| + } |
| + |
| + /** |
| + * Called once the image requested by {@link #fetchHomescreenImage()} is fetched in order to run |
| + * the Java callback. |
| + */ |
| + @CalledByNative |
| + public static void onFetchedHomescreenImage( |
| + Bitmap bitmap, long murmur2Hash, FetchHomescreenImageCallback callback) { |
| + callback.onFetchedHomescreenImage(bitmap, murmur2Hash); |
| + } |
| + |
| + /** |
| * Returns true if WebAPKs are enabled and there is a WebAPK installed which can handle |
| * {@link url}. |
| */ |
| @@ -578,5 +605,7 @@ public class ShortcutHelper { |
| return null; |
| } |
| + private static native void nativeFetchHomescreenImage( |
| + WebContents webContents, String imageUrl, FetchHomescreenImageCallback callback); |
| private static native void nativeOnWebappDataStored(long callbackPointer); |
| } |