Chromium Code Reviews| 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 3bc0215aa32197507566c8d2811c27bf06999507..70bec56100129d882b972a67a31f1741a0df9fed 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 |
| @@ -27,7 +27,8 @@ public class WebappInfo { |
| private String mId; |
| private Bitmap mIcon; |
| private Uri mUri; |
| - private String mTitle; |
| + private String mName; |
| + private String mShortName; |
| private int mOrientation; |
| private int mSource; |
| @@ -35,6 +36,24 @@ public class WebappInfo { |
| return new WebappInfo(); |
| } |
| + public static String titleFromIntent(Intent intent) { |
|
mlamouri (slow - plz ping)
2015/07/21 10:24:47
I don't think you need to expose titleFromIntent.
|
| + // 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, |
| + // we set the name and shortName to be the title. |
| + String title = intent.getStringExtra(ShortcutHelper.EXTRA_TITLE); |
| + return title == null ? "" : title; |
| + } |
| + |
| + public static String nameFromIntent(Intent intent, String title) { |
| + String name = intent.getStringExtra(ShortcutHelper.EXTRA_NAME); |
| + return name == null ? title : name; |
| + } |
| + |
| + public static String shortNameFromIntent(Intent intent, String title) { |
| + String shortName = intent.getStringExtra(ShortcutHelper.EXTRA_SHORT_NAME); |
| + return shortName == null ? title : shortName; |
| + } |
| + |
| /** |
| * Construct a WebappInfo. |
| * @param intent Intent containing info about the app. |
| @@ -42,13 +61,17 @@ public class WebappInfo { |
| public static WebappInfo create(Intent intent) { |
| String id = intent.getStringExtra(ShortcutHelper.EXTRA_ID); |
| String icon = intent.getStringExtra(ShortcutHelper.EXTRA_ICON); |
| - String title = intent.getStringExtra(ShortcutHelper.EXTRA_TITLE); |
| String url = intent.getStringExtra(ShortcutHelper.EXTRA_URL); |
| int orientation = intent.getIntExtra( |
| ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValues.DEFAULT); |
| int source = intent.getIntExtra( |
| ShortcutHelper.EXTRA_SOURCE, ShortcutSource.UNKNOWN); |
| - return create(id, url, icon, title, orientation, source); |
| + |
| + String title = titleFromIntent(intent); |
| + String name = nameFromIntent(intent, title); |
| + String shortName = shortNameFromIntent(intent, title); |
| + |
| + return create(id, url, icon, name, shortName, orientation, source); |
| } |
| /** |
| @@ -56,12 +79,13 @@ public class WebappInfo { |
| * @param id ID for the webapp. |
| * @param url URL for the webapp. |
| * @param icon Icon to show for the webapp. |
| - * @param title Title of the webapp. |
| + * @param name Name of the webapp. |
| + * @param shortName The short name of the webapp. |
| * @param orientation Orientation of the webapp. |
| * @param source Source where the webapp was added from. |
| */ |
| - public static WebappInfo create(String id, String url, String icon, String title, |
| - int orientation, int source) { |
| + public static WebappInfo create(String id, String url, String icon, String name, |
| + String shortName, int orientation, int source) { |
| if (id == null || url == null) { |
| Log.e("WebappInfo", "Data passed in was incomplete: " + id + ", " + url); |
| return null; |
| @@ -74,13 +98,15 @@ public class WebappInfo { |
| } |
| Uri uri = Uri.parse(url); |
| - return new WebappInfo(id, uri, favicon, title, orientation, source); |
| + return new WebappInfo(id, uri, favicon, name, shortName, orientation, source); |
| } |
| - private WebappInfo(String id, Uri uri, Bitmap icon, String title, int orientation, int source) { |
| + private WebappInfo(String id, Uri uri, Bitmap icon, String name, |
| + String shortName, int orientation, int source) { |
| mIcon = icon; |
| mId = id; |
| - mTitle = title; |
| + mName = name; |
| + mShortName = shortName; |
| mUri = uri; |
| mOrientation = orientation; |
| mSource = source; |
| @@ -100,7 +126,8 @@ public class WebappInfo { |
| outState.putString(ShortcutHelper.EXTRA_ID, mId); |
| outState.putString(ShortcutHelper.EXTRA_URL, mUri.toString()); |
| outState.putParcelable(ShortcutHelper.EXTRA_ICON, mIcon); |
| - outState.putString(ShortcutHelper.EXTRA_TITLE, mTitle); |
| + outState.putString(ShortcutHelper.EXTRA_NAME, mName); |
| + outState.putString(ShortcutHelper.EXTRA_SHORT_NAME, mShortName); |
| outState.putInt(ShortcutHelper.EXTRA_ORIENTATION, mOrientation); |
| outState.putInt(ShortcutHelper.EXTRA_SOURCE, mSource); |
| } |
| @@ -114,7 +141,8 @@ public class WebappInfo { |
| mIcon = newInfo.mIcon; |
| mId = newInfo.mId; |
| mUri = newInfo.mUri; |
| - mTitle = newInfo.mTitle; |
| + mName = newInfo.mName; |
| + mShortName = newInfo.mShortName; |
| mOrientation = newInfo.mOrientation; |
| mSource = newInfo.mSource; |
| } |
| @@ -135,8 +163,12 @@ public class WebappInfo { |
| return mIcon; |
| } |
| - public String title() { |
| - return mTitle; |
| + public String name() { |
| + return mName; |
| + } |
| + |
| + public String shortName() { |
| + return mShortName; |
| } |
| public int orientation() { |