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

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

Issue 2457663002: Merge WebappInfo and WebApkMetaData part 1/2 (Closed)
Patch Set: Merge branch 'master' into update_fail_refactor00 Created 4 years, 1 month 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 5a2c9de1dced4259d4a9d8348be29644e7094f14..481ed32da5f9f67579045050dc5520a787aa6dbe 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
@@ -7,8 +7,9 @@ package org.chromium.chrome.browser.webapps;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
-import android.util.Log;
+import android.text.TextUtils;
+import org.chromium.base.Log;
import org.chromium.blink_public.platform.WebDisplayMode;
import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.ShortcutSource;
@@ -19,6 +20,8 @@ import org.chromium.content_public.common.ScreenOrientationValues;
* Stores info about a web app.
*/
public class WebappInfo {
+ private static final String TAG = "WebappInfo";
+
private boolean mIsInitialized;
private String mId;
private String mEncodedIcon;
@@ -33,12 +36,20 @@ public class WebappInfo {
private long mThemeColor;
private long mBackgroundColor;
private boolean mIsIconGenerated;
- private String mWebApkPackageName;
public static WebappInfo createEmpty() {
return new WebappInfo();
}
+ protected static String urlFromIntent(Intent intent) {
+ return IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_URL);
+ }
+
+ protected static int sourceFromIntent(Intent intent) {
+ return IntentUtils.safeGetIntExtra(
+ intent, ShortcutHelper.EXTRA_SOURCE, ShortcutSource.UNKNOWN);
+ }
+
private static String titleFromIntent(Intent intent) {
// The reference to title has been kept for reasons of backward compatibility. For intents
// and shortcuts which were created before we utilized the concept of name and shortName,
@@ -47,12 +58,12 @@ public class WebappInfo {
return title == null ? "" : title;
}
- public static String nameFromIntent(Intent intent) {
+ private static String nameFromIntent(Intent intent) {
String name = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_NAME);
return name == null ? titleFromIntent(intent) : name;
}
- public static String shortNameFromIntent(Intent intent) {
+ private static String shortNameFromIntent(Intent intent) {
String shortName = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_SHORT_NAME);
return shortName == null ? titleFromIntent(intent) : shortName;
}
@@ -64,14 +75,13 @@ public class WebappInfo {
public static WebappInfo create(Intent intent) {
String id = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ID);
String icon = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ICON);
- String url = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_URL);
+ String url = urlFromIntent(intent);
String scope = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_SCOPE);
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);
+ int source = sourceFromIntent(intent);
long themeColor = IntentUtils.safeGetLongExtra(intent,
ShortcutHelper.EXTRA_THEME_COLOR,
ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING);
@@ -83,11 +93,9 @@ public class WebappInfo {
String name = nameFromIntent(intent);
String shortName = shortNameFromIntent(intent);
- String webApkPackageName = IntentUtils.safeGetStringExtra(intent,
- ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME);
return create(id, url, scope, icon, name, shortName, displayMode, orientation, source,
- themeColor, backgroundColor, isIconGenerated, webApkPackageName);
+ themeColor, backgroundColor, isIconGenerated);
}
/**
@@ -104,30 +112,28 @@ public class WebappInfo {
* @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.
*/
public static WebappInfo create(String id, String url, String scope, String icon, String name,
String shortName, int displayMode, int orientation, int source, long themeColor,
- long backgroundColor, boolean isIconGenerated, String webApkPackageName) {
+ long backgroundColor, boolean isIconGenerated) {
if (id == null || url == null) {
- Log.e("WebappInfo", "Data passed in was incomplete: " + id + ", " + url);
+ Log.e(TAG, "Incomplete data provided: " + id + ", " + url);
return null;
}
+ return new WebappInfo(id, url, scope, icon, name, shortName, displayMode, orientation,
+ source, themeColor, backgroundColor, isIconGenerated);
+ }
+
+ protected WebappInfo(String id, String url, String scope, String encodedIcon, String name,
+ String shortName, int displayMode, int orientation, int source, long themeColor,
+ long backgroundColor, boolean isIconGenerated) {
Uri uri = Uri.parse(url);
- if (scope == null || scope.isEmpty()) {
+ if (TextUtils.isEmpty(scope)) {
scope = ShortcutHelper.getScopeFromUrl(url);
}
Uri scopeUri = Uri.parse(scope);
- Uri webManifestUri = null;
- return new WebappInfo(id, uri, scopeUri, icon, name, shortName, displayMode, orientation,
- source, themeColor, backgroundColor, isIconGenerated, webApkPackageName);
- }
- private WebappInfo(String id, Uri uri, Uri scopeUri, String encodedIcon, String name,
- String shortName, int displayMode, int orientation, int source, long themeColor,
- long backgroundColor, boolean isIconGenerated, String webApkPackageName) {
mEncodedIcon = encodedIcon;
mId = id;
mName = name;
@@ -141,10 +147,9 @@ public class WebappInfo {
mBackgroundColor = backgroundColor;
mIsIconGenerated = isIconGenerated;
mIsInitialized = mUri != null;
- mWebApkPackageName = webApkPackageName;
}
- private WebappInfo() {
+ protected WebappInfo() {
}
public boolean isInitialized() {
@@ -176,7 +181,7 @@ public class WebappInfo {
}
public String webApkPackageName() {
- return mWebApkPackageName;
+ return null;
}
public int orientation() {

Powered by Google App Engine
This is Rietveld 408576698