| 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 6aef70fc5d81046a2cc4ac6be6692d7b533fac2e..2d2cf272a4e795e8c881ff9483afc23ff06284ea 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java
|
| @@ -39,6 +39,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.net.GURLUtils;
|
| import org.chromium.ui.widget.Toast;
|
| @@ -101,6 +102,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 {
|
| /**
|
| @@ -446,6 +455,24 @@ public class ShortcutHelper {
|
| }
|
|
|
| /**
|
| + * Fetches the image at {@link iconUrl} and scales it so that it can be used on the homescreen.
|
| + */
|
| + 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}.
|
| */
|
| @@ -602,5 +629,7 @@ public class ShortcutHelper {
|
| return null;
|
| }
|
|
|
| + private static native void nativeFetchHomescreenImage(
|
| + WebContents webContents, String imageUrl, FetchHomescreenImageCallback callback);
|
| private static native void nativeOnWebappDataStored(long callbackPointer);
|
| }
|
|
|