| 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 481ed32da5f9f67579045050dc5520a787aa6dbe..518e9fdcc00b4b7a106b216b54e1bf7755f783f4 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
|
| @@ -22,10 +22,40 @@ import org.chromium.content_public.common.ScreenOrientationValues;
|
| public class WebappInfo {
|
| private static final String TAG = "WebappInfo";
|
|
|
| + /**
|
| + * Parameter for {@link WebappInfo#create()} method which allows either a Bitmap or a PNG
|
| + * encoded string to be passed as a parameter.
|
| + */
|
| + public static class Icon {
|
| + private String mEncoded;
|
| + private Bitmap mDecoded;
|
| +
|
| + public Icon(String encoded) {
|
| + mEncoded = encoded;
|
| + }
|
| +
|
| + public Icon(Bitmap decoded) {
|
| + mDecoded = decoded;
|
| + }
|
| +
|
| + public String encoded() {
|
| + if (mEncoded == null) {
|
| + mEncoded = ShortcutHelper.encodeBitmapAsString(mDecoded);
|
| + }
|
| + return mEncoded;
|
| + }
|
| +
|
| + public Bitmap decoded() {
|
| + if (mDecoded == null) {
|
| + mDecoded = ShortcutHelper.decodeBitmapFromString(mEncoded);
|
| + }
|
| + return mDecoded;
|
| + }
|
| + }
|
| +
|
| private boolean mIsInitialized;
|
| private String mId;
|
| - private String mEncodedIcon;
|
| - private Bitmap mDecodedIcon;
|
| + private Icon mIcon;
|
| private Uri mUri;
|
| private Uri mScopeUri;
|
| private String mName;
|
| @@ -94,8 +124,8 @@ public class WebappInfo {
|
| String name = nameFromIntent(intent);
|
| String shortName = shortNameFromIntent(intent);
|
|
|
| - return create(id, url, scope, icon, name, shortName, displayMode, orientation, source,
|
| - themeColor, backgroundColor, isIconGenerated);
|
| + return create(id, url, scope, new Icon(icon), name, shortName, displayMode,
|
| + orientation, source, themeColor, backgroundColor, isIconGenerated);
|
| }
|
|
|
| /**
|
| @@ -113,7 +143,7 @@ public class WebappInfo {
|
| * @param backgroundColor The background color of the webapp.
|
| * @param isIconGenerated Whether the |icon| was generated by Chromium.
|
| */
|
| - public static WebappInfo create(String id, String url, String scope, String icon, String name,
|
| + public static WebappInfo create(String id, String url, String scope, Icon icon, String name,
|
| String shortName, int displayMode, int orientation, int source, long themeColor,
|
| long backgroundColor, boolean isIconGenerated) {
|
| if (id == null || url == null) {
|
| @@ -125,7 +155,7 @@ public class WebappInfo {
|
| source, themeColor, backgroundColor, isIconGenerated);
|
| }
|
|
|
| - protected WebappInfo(String id, String url, String scope, String encodedIcon, String name,
|
| + protected WebappInfo(String id, String url, String scope, Icon icon, String name,
|
| String shortName, int displayMode, int orientation, int source, long themeColor,
|
| long backgroundColor, boolean isIconGenerated) {
|
| Uri uri = Uri.parse(url);
|
| @@ -134,7 +164,7 @@ public class WebappInfo {
|
| }
|
| Uri scopeUri = Uri.parse(scope);
|
|
|
| - mEncodedIcon = encodedIcon;
|
| + mIcon = icon;
|
| mId = id;
|
| mName = name;
|
| mShortName = shortName;
|
| @@ -235,18 +265,16 @@ public class WebappInfo {
|
| return hasValidBackgroundColor() ? (int) mBackgroundColor : fallback;
|
| }
|
|
|
| - // This is needed for clients that want to send the icon trough an intent.
|
| + // This is needed for clients that want to send the icon through an intent.
|
| public String encodedIcon() {
|
| - return mEncodedIcon;
|
| + return (mIcon == null) ? null : mIcon.encoded();
|
| }
|
|
|
| /**
|
| * Returns the icon in Bitmap form. Caches the result for future retrievals.
|
| */
|
| public Bitmap icon() {
|
| - if (mDecodedIcon != null) return mDecodedIcon;
|
| - mDecodedIcon = ShortcutHelper.decodeBitmapFromString(mEncodedIcon);
|
| - return mDecodedIcon;
|
| + return (mIcon == null) ? null : mIcon.decoded();
|
| }
|
|
|
| /**
|
|
|