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

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

Issue 2206493002: Update WebAPK if homescreen icon changed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable http/tests/serviceworker/registration.html Created 4 years, 4 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/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);
}

Powered by Google App Engine
This is Rietveld 408576698