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

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

Issue 2050933002: Upstream: Add additional checks before creating a WebAPK after clicking "Add to Homescreen" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 923b9bbd469e555e65c095a873234355cb400679..85134a35babfb7e6f232484450b43a466bee8445 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java
@@ -28,13 +28,11 @@ import android.text.TextUtils;
import android.util.Base64;
import org.chromium.base.ApiCompatibilityUtils;
-import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
-import org.chromium.blink_public.platform.WebDisplayMode;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.webapps.WebApkBuilder;
import org.chromium.chrome.browser.webapps.WebappAuthenticator;
@@ -140,7 +138,7 @@ public class ShortcutHelper {
*/
@SuppressWarnings("unused")
@CalledByNative
- private static void addShortcut(String id, String url, final String userTitle,
+ private static void addShortcut(String id, int shortcutType, String url, final String userTitle,
String name, String shortName, Bitmap icon, int displayMode, int orientation,
int source, long themeColor, long backgroundColor, boolean isIconGenerated,
final long callbackPointer) {
@@ -148,16 +146,14 @@ public class ShortcutHelper {
Context context = ContextUtils.getApplicationContext();
final Intent shortcutIntent;
- boolean isWebappCapable = (displayMode == WebDisplayMode.Standalone
- || displayMode == WebDisplayMode.Fullscreen);
- if (isWebappCapable) {
- if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_WEBAPK)) {
- WebApkBuilder apkBuilder = ((ChromeApplication) context).createWebApkBuilder();
- if (apkBuilder != null) {
- apkBuilder.buildWebApkAsync(url, GURLUtils.getOrigin(url), shortName, icon);
- return;
- }
+ if (shortcutType == ShortcutType.WEBAPK) {
+ WebApkBuilder apkBuilder = ((ChromeApplication) context).createWebApkBuilder();
+ if (apkBuilder != null) {
+ apkBuilder.buildWebApkAsync(url, GURLUtils.getOrigin(url), shortName, icon);
+ return;
}
+ }
+ if (shortcutType == ShortcutType.WEBAPP) {
shortcutIntent = createWebappShortcutIntent(id, sDelegate.getFullscreenAction(), url,
getScopeFromUrl(url), name, shortName, icon, WEBAPP_SHORTCUT_VERSION,
displayMode, orientation, themeColor, backgroundColor, isIconGenerated);
@@ -174,7 +170,7 @@ public class ShortcutHelper {
sDelegate.sendBroadcast(
context, createAddToHomeIntent(url, userTitle, icon, shortcutIntent));
- if (isWebappCapable) {
+ if (shortcutType == ShortcutType.WEBAPP) {
// Store the webapp data so that it is accessible without the intent. Once this process
// is complete, call back to native code to start the splash image download.
WebappRegistry.registerWebapp(context, id,

Powered by Google App Engine
This is Rietveld 408576698