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

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

Issue 2409483002: Read the bare minimum of data from the WebAPK launch intent. (Closed)
Patch Set: Merge branch 'startup_crash0' into security Created 4 years, 2 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/webapps/WebappInfo.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappInfo.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappInfo.java
index 4b2a9010d05eb2262971a4c9f67b37a5cf5b7b6e..5a2c9de1dced4259d4a9d8348be29644e7094f14 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappInfo.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappInfo.java
@@ -14,7 +14,6 @@ import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.ShortcutSource;
import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.content_public.common.ScreenOrientationValues;
-import org.chromium.webapk.lib.common.WebApkConstants;
/**
* Stores info about a web app.
@@ -58,58 +57,6 @@ public class WebappInfo {
return shortName == null ? titleFromIntent(intent) : shortName;
}
- public static int displayModeFromIntent(Intent intent) {
- String displayMode =
- IntentUtils.safeGetStringExtra(intent, WebApkConstants.EXTRA_WEBAPK_DISPLAY_MODE);
- if (displayMode == null) {
- return IntentUtils.safeGetIntExtra(
- intent, ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.Standalone);
- }
-
- // {@link displayMode} should be one of
- // https://w3c.github.io/manifest/#dfn-display-modes-values
- if (displayMode.equals("fullscreen")) {
- return WebDisplayMode.Fullscreen;
- } else if (displayMode.equals("minimal-ui")) {
- return WebDisplayMode.MinimalUi;
- } else if (displayMode.equals("browser")) {
- return WebDisplayMode.Browser;
- } else {
- return WebDisplayMode.Standalone;
- }
- }
-
- public static int orientationFromIntent(Intent intent) {
- String orientation =
- IntentUtils.safeGetStringExtra(intent, WebApkConstants.EXTRA_WEBAPK_ORIENTATION);
- if (orientation == null) {
- return IntentUtils.safeGetIntExtra(
- intent, ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValues.DEFAULT);
- }
-
- // {@link orientation} should be one of
- // w3c.github.io/screen-orientation/#orientationlocktype-enum
- if (orientation.equals("any")) {
- return ScreenOrientationValues.ANY;
- } else if (orientation.equals("natural")) {
- return ScreenOrientationValues.NATURAL;
- } else if (orientation.equals("landscape")) {
- return ScreenOrientationValues.LANDSCAPE;
- } else if (orientation.equals("landscape-primary")) {
- return ScreenOrientationValues.LANDSCAPE_PRIMARY;
- } else if (orientation.equals("landscape-secondary")) {
- return ScreenOrientationValues.LANDSCAPE_SECONDARY;
- } else if (orientation.equals("portrait")) {
- return ScreenOrientationValues.PORTRAIT;
- } else if (orientation.equals("portrait-primary")) {
- return ScreenOrientationValues.PORTRAIT_PRIMARY;
- } else if (orientation.equals("portrait-secondary")) {
- return ScreenOrientationValues.PORTRAIT_SECONDARY;
- } else {
- return ScreenOrientationValues.DEFAULT;
- }
- }
-
/**
* Construct a WebappInfo.
* @param intent Intent containing info about the app.
@@ -119,8 +66,10 @@ public class WebappInfo {
String icon = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ICON);
String url = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_URL);
String scope = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_SCOPE);
- int displayMode = displayModeFromIntent(intent);
- int orientation = orientationFromIntent(intent);
+ int displayMode = IntentUtils.safeGetIntExtra(
+ intent, ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.Standalone);
+ int orientation = IntentUtils.safeGetIntExtra(
+ intent, ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValues.DEFAULT);
int source = IntentUtils.safeGetIntExtra(intent,
ShortcutHelper.EXTRA_SOURCE, ShortcutSource.UNKNOWN);
long themeColor = IntentUtils.safeGetLongExtra(intent,
@@ -153,6 +102,7 @@ public class WebappInfo {
* @param orientation Orientation of the webapp.
* @param source Source where the webapp was added from.
* @param themeColor The theme color of the webapp.
+ * @param backgroundColor The background color of the webapp.
* @param isIconGenerated Whether the |icon| was generated by Chromium.
* @param webApkPackageName The package of the WebAPK associated with the webapp. Null if
* no WebAPK is associated with the webapp.

Powered by Google App Engine
This is Rietveld 408576698