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

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

Issue 1989283002: Upstream: Launch WebApkActivity from WebAPK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 179991e89dc477e4ae99fcb1c28e8fc872628e7e..e90547b844b49167090a5c4241181a1c310784fe 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
@@ -23,6 +23,7 @@ public class WebappInfo {
private String mEncodedIcon;
private Bitmap mDecodedIcon;
private Uri mUri;
+ private Uri mScope;
pkotwicz 2016/05/18 23:00:17 I don't think that this member is needed at all. I
Xi Han 2016/05/19 18:31:49 Since WebAPK will have two scopes, the "launch sco
private String mName;
private String mShortName;
private int mOrientation;
@@ -30,11 +31,17 @@ public class WebappInfo {
private long mThemeColor;
private long mBackgroundColor;
private boolean mIsIconGenerated;
+ private String mPackageName;
public static WebappInfo createEmpty() {
return new WebappInfo();
}
+ public static String scopeFromIntent(Intent intent) {
+ String scope = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_SCOPE);
+ return scope == null ? "" : scope;
+ }
+
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,
@@ -53,6 +60,12 @@ public class WebappInfo {
return shortName == null ? titleFromIntent(intent) : shortName;
}
+ public static String packageNameFromIntent(Intent intent) {
+ String packageName = IntentUtils.safeGetStringExtra(
+ intent, ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME);
+ return packageName == null ? "" : packageName;
+ }
+
/**
* Construct a WebappInfo.
* @param intent Intent containing info about the app.
@@ -61,6 +74,7 @@ public class WebappInfo {
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 scope = scopeFromIntent(intent);
int orientation = IntentUtils.safeGetIntExtra(intent,
ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValues.DEFAULT);
int source = IntentUtils.safeGetIntExtra(intent,
@@ -76,15 +90,17 @@ public class WebappInfo {
String name = nameFromIntent(intent);
String shortName = shortNameFromIntent(intent);
+ String packageName = packageNameFromIntent(intent);
- return create(id, url, icon, name, shortName, orientation, source,
- themeColor, backgroundColor, isIconGenerated);
+ return create(id, url, scope, icon, name, shortName, orientation, source,
+ themeColor, backgroundColor, isIconGenerated, packageName);
}
/**
* Construct a WebappInfo.
* @param id ID for the webapp.
* @param url URL for the webapp.
+ * @param scope Scope of URLs that the WebAPK can navigate to.
* @param icon Icon to show for the webapp.
* @param name Name of the webapp.
* @param shortName The short name of the webapp.
@@ -92,58 +108,44 @@ public class WebappInfo {
* @param source Source where the webapp was added from.
* @param themeColor The theme color of the webapp.
* @param isIconGenerated Whether the |icon| was generated by Chromium.
+ * @param packageName The package name of the WebAPK that intents to start the WebApp
+ * activity.
*/
- public static WebappInfo create(String id, String url, String icon, String name,
- String shortName, int orientation, int source, long themeColor,
- long backgroundColor, boolean isIconGenerated) {
+ public static WebappInfo create(String id, String url, String scope, String icon, String name,
+ String shortName, int orientation, int source, long themeColor, long backgroundColor,
+ boolean isIconGenerated, String packageName) {
if (id == null || url == null) {
Log.e("WebappInfo", "Data passed in was incomplete: " + id + ", " + url);
return null;
}
Uri uri = Uri.parse(url);
- return new WebappInfo(id, uri, icon, name, shortName, orientation, source,
- themeColor, backgroundColor, isIconGenerated);
+ Uri scope_uri = scope == null ? Uri.parse("") : Uri.parse(scope);
+ return new WebappInfo(id, uri, scope_uri, icon, name, shortName, orientation, source,
+ themeColor, backgroundColor, isIconGenerated, packageName);
}
- private WebappInfo(String id, Uri uri, String encodedIcon, String name,
- String shortName, int orientation, int source, long themeColor,
- long backgroundColor, boolean isIconGenerated) {
+ private WebappInfo(String id, Uri uri, Uri scope, String encodedIcon, String name,
+ String shortName, int orientation, int source, long themeColor, long backgroundColor,
+ boolean isIconGenerated, String packageName) {
mEncodedIcon = encodedIcon;
mId = id;
mName = name;
mShortName = shortName;
mUri = uri;
+ mScope = scope;
mOrientation = orientation;
mSource = source;
mThemeColor = themeColor;
mBackgroundColor = backgroundColor;
mIsIconGenerated = isIconGenerated;
mIsInitialized = mUri != null;
+ mPackageName = packageName;
}
private WebappInfo() {
}
- /**
- * Copies all the fields from the given WebappInfo into this instance.
- * @param newInfo Information about the new webapp.
- */
- void copy(WebappInfo newInfo) {
- mIsInitialized = newInfo.mIsInitialized;
- mEncodedIcon = newInfo.mEncodedIcon;
- mDecodedIcon = newInfo.mDecodedIcon;
- mId = newInfo.mId;
- mUri = newInfo.mUri;
- mName = newInfo.mName;
- mShortName = newInfo.mShortName;
- mOrientation = newInfo.mOrientation;
- mSource = newInfo.mSource;
- mThemeColor = newInfo.mThemeColor;
- mBackgroundColor = newInfo.mBackgroundColor;
- mIsIconGenerated = newInfo.mIsIconGenerated;
- }
-
public boolean isInitialized() {
return mIsInitialized;
}
@@ -156,6 +158,10 @@ public class WebappInfo {
return mUri;
}
+ public Uri scope() {
+ return mScope;
+ }
+
public String name() {
return mName;
}
@@ -164,6 +170,10 @@ public class WebappInfo {
return mShortName;
}
pkotwicz 2016/05/18 23:00:17 Can we rename this function to getWebApkPackage()
Xi Han 2016/05/19 18:31:50 Change to WebApkPackageName.
+ public String packageName() {
+ return mPackageName;
+ }
+
public int orientation() {
return mOrientation;
}
@@ -243,8 +253,7 @@ public class WebappInfo {
public void setWebappIntentExtras(Intent intent) {
intent.putExtra(ShortcutHelper.EXTRA_ID, id());
intent.putExtra(ShortcutHelper.EXTRA_URL, uri().toString());
- intent.putExtra(ShortcutHelper.EXTRA_SCOPE,
- ShortcutHelper.getScopeFromUrl(uri().toString()));
+ intent.putExtra(ShortcutHelper.EXTRA_SCOPE, scope().toString());
intent.putExtra(ShortcutHelper.EXTRA_ICON, encodedIcon());
intent.putExtra(ShortcutHelper.EXTRA_VERSION, ShortcutHelper.WEBAPP_SHORTCUT_VERSION);
intent.putExtra(ShortcutHelper.EXTRA_NAME, name());
@@ -254,6 +263,7 @@ public class WebappInfo {
intent.putExtra(ShortcutHelper.EXTRA_THEME_COLOR, themeColor());
intent.putExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, backgroundColor());
intent.putExtra(ShortcutHelper.EXTRA_IS_ICON_GENERATED, isIconGenerated());
+ intent.putExtra(ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME, packageName());
}
/**

Powered by Google App Engine
This is Rietveld 408576698