Commit 911d0c1b authored by Rayan Kanso's avatar Rayan Kanso Committed by Commit Bot

[Shortcuts] Include the shortcut icon url in the shell.

This is needed for the stale manifest use case.

Bug: 1045588
Change-Id: I7deb018afa062f829cc13247ab7faaa86da8a129
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050274Reviewed-by: default avatarPeter Kotwicz <pkotwicz@chromium.org>
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743057}
parent d8e3222d
...@@ -62,6 +62,7 @@ public class WebApkIntentDataProviderFactory { ...@@ -62,6 +62,7 @@ public class WebApkIntentDataProviderFactory {
private static final String SHORTCUT_NAME_ATTRIBUTE = "shortcutLongLabel"; private static final String SHORTCUT_NAME_ATTRIBUTE = "shortcutLongLabel";
private static final String SHORTCUT_SHORT_NAME_ATTRIBUTE = "shortcutShortLabel"; private static final String SHORTCUT_SHORT_NAME_ATTRIBUTE = "shortcutShortLabel";
private static final String SHORTCUT_ICON_HASH_ATTRIBUTE = "iconHash"; private static final String SHORTCUT_ICON_HASH_ATTRIBUTE = "iconHash";
private static final String SHORTCUT_ICON_URL_ATTRIBUTE = "iconUrl";
private static final String SHORTCUT_INTENT_LAUNCH_URL_ATTRIBUTE = "data"; private static final String SHORTCUT_INTENT_LAUNCH_URL_ATTRIBUTE = "data";
private static final String TAG = "WebApkInfo"; private static final String TAG = "WebApkInfo";
...@@ -166,6 +167,7 @@ public class WebApkIntentDataProviderFactory { ...@@ -166,6 +167,7 @@ public class WebApkIntentDataProviderFactory {
SHORTCUT_ATTRIBUTE_NAMESPACE, SHORTCUT_NAME_ATTRIBUTE, 0); SHORTCUT_ATTRIBUTE_NAMESPACE, SHORTCUT_NAME_ATTRIBUTE, 0);
int shortNameResId = parser.getAttributeResourceValue( int shortNameResId = parser.getAttributeResourceValue(
SHORTCUT_ATTRIBUTE_NAMESPACE, SHORTCUT_SHORT_NAME_ATTRIBUTE, 0); SHORTCUT_ATTRIBUTE_NAMESPACE, SHORTCUT_SHORT_NAME_ATTRIBUTE, 0);
String iconUrl = parser.getAttributeValue(null, SHORTCUT_ICON_URL_ATTRIBUTE);
String iconHash = parser.getAttributeValue(null, SHORTCUT_ICON_HASH_ATTRIBUTE); String iconHash = parser.getAttributeValue(null, SHORTCUT_ICON_HASH_ATTRIBUTE);
eventType = parser.next(); eventType = parser.next();
...@@ -178,11 +180,9 @@ public class WebApkIntentDataProviderFactory { ...@@ -178,11 +180,9 @@ public class WebApkIntentDataProviderFactory {
String launchUrl = parser.getAttributeValue( String launchUrl = parser.getAttributeValue(
SHORTCUT_ATTRIBUTE_NAMESPACE, SHORTCUT_INTENT_LAUNCH_URL_ATTRIBUTE); SHORTCUT_ATTRIBUTE_NAMESPACE, SHORTCUT_INTENT_LAUNCH_URL_ATTRIBUTE);
// The |iconUrl| is not required, only a change in the icon hash will trigger an
// update.
shortcuts.add(new ShortcutItem(nameResId != 0 ? res.getString(nameResId) : "", shortcuts.add(new ShortcutItem(nameResId != 0 ? res.getString(nameResId) : "",
shortNameResId != 0 ? res.getString(shortNameResId) : "", launchUrl, shortNameResId != 0 ? res.getString(shortNameResId) : "", launchUrl,
"" /* iconUrl */, iconHash)); iconUrl, iconHash));
} }
eventType = parser.next(); eventType = parser.next();
} }
......
...@@ -728,6 +728,7 @@ public class WebApkInfoTest { ...@@ -728,6 +728,7 @@ public class WebApkInfoTest {
+ " <shortcut" + " <shortcut"
+ " android:shortcutId='shortcut_1'" + " android:shortcutId='shortcut_1'"
+ " android:icon='@drawable/shortcut_1_icon'" + " android:icon='@drawable/shortcut_1_icon'"
+ " iconUrl='https://example.com/icon1.png'"
+ " iconHash='1234'" + " iconHash='1234'"
+ " android:shortcutShortLabel='@string/shortcut_1_short_name'" + " android:shortcutShortLabel='@string/shortcut_1_short_name'"
+ " android:shortcutLongLabel='@string/shortcut_1_name'>" + " android:shortcutLongLabel='@string/shortcut_1_name'>"
...@@ -742,6 +743,7 @@ public class WebApkInfoTest { ...@@ -742,6 +743,7 @@ public class WebApkInfoTest {
Assert.assertEquals(item.name, "name1"); Assert.assertEquals(item.name, "name1");
Assert.assertEquals(item.shortName, "short name1"); Assert.assertEquals(item.shortName, "short name1");
Assert.assertEquals(item.launchUrl, "https://example.com/launch1"); Assert.assertEquals(item.launchUrl, "https://example.com/launch1");
Assert.assertEquals(item.iconUrl, "https://example.com/icon1.png");
Assert.assertEquals(item.iconHash, "1234"); Assert.assertEquals(item.iconHash, "1234");
// Multiple shortcuts case. // Multiple shortcuts case.
...@@ -750,6 +752,7 @@ public class WebApkInfoTest { ...@@ -750,6 +752,7 @@ public class WebApkInfoTest {
+ " <shortcut" + " <shortcut"
+ " android:shortcutId='shortcut_1'" + " android:shortcutId='shortcut_1'"
+ " android:icon='@drawable/shortcut_1_icon'" + " android:icon='@drawable/shortcut_1_icon'"
+ " iconUrl='https://example.con/icon1.png'"
+ " iconHash='1234'" + " iconHash='1234'"
+ " android:shortcutShortLabel='@string/shortcut_1_short_name'" + " android:shortcutShortLabel='@string/shortcut_1_short_name'"
+ " android:shortcutLongLabel='@string/shortcut_1_name'>" + " android:shortcutLongLabel='@string/shortcut_1_name'>"
...@@ -758,6 +761,7 @@ public class WebApkInfoTest { ...@@ -758,6 +761,7 @@ public class WebApkInfoTest {
+ " <shortcut" + " <shortcut"
+ " android:shortcutId='shortcut_2'" + " android:shortcutId='shortcut_2'"
+ " android:icon='@drawable/shortcut_2_icon'" + " android:icon='@drawable/shortcut_2_icon'"
+ " iconUrl='https://example.com/icon2.png'"
+ " iconHash='2345'" + " iconHash='2345'"
+ " android:shortcutShortLabel='@string/shortcut_2_short_name'" + " android:shortcutShortLabel='@string/shortcut_2_short_name'"
+ " android:shortcutLongLabel='@string/shortcut_2_name'>" + " android:shortcutLongLabel='@string/shortcut_2_name'>"
...@@ -772,6 +776,7 @@ public class WebApkInfoTest { ...@@ -772,6 +776,7 @@ public class WebApkInfoTest {
Assert.assertEquals(item.name, "name2"); Assert.assertEquals(item.name, "name2");
Assert.assertEquals(item.shortName, "short name2"); Assert.assertEquals(item.shortName, "short name2");
Assert.assertEquals(item.launchUrl, "https://example.com/launch2"); Assert.assertEquals(item.launchUrl, "https://example.com/launch2");
Assert.assertEquals(item.iconUrl, "https://example.com/icon2.png");
Assert.assertEquals(item.iconHash, "2345"); Assert.assertEquals(item.iconHash, "2345");
} }
} }
...@@ -12,4 +12,4 @@ ...@@ -12,4 +12,4 @@
# //chrome/android/webapk/shell_apk:webapk is changed. This includes # //chrome/android/webapk/shell_apk:webapk is changed. This includes
# Java files, Android resource files and AndroidManifest.xml. Does not affect # Java files, Android resource files and AndroidManifest.xml. Does not affect
# Chrome.apk # Chrome.apk
current_shell_apk_version = 121 current_shell_apk_version = 122
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<shortcut <shortcut
android:shortcutId='shortcut_1' android:shortcutId='shortcut_1'
android:icon='@drawable/shortcut_1_icon' android:icon='@drawable/shortcut_1_icon'
iconUrl='{{{icon_url}}}'
iconHash='{{{icon_hash}}}' iconHash='{{{icon_hash}}}'
android:shortcutShortLabel='@string/shortcut_1_short_name' android:shortcutShortLabel='@string/shortcut_1_short_name'
android:shortcutLongLabel='@string/shortcut_1_name'> android:shortcutLongLabel='@string/shortcut_1_name'>
...@@ -19,6 +20,7 @@ ...@@ -19,6 +20,7 @@
<shortcut <shortcut
android:shortcutId='shortcut_2' android:shortcutId='shortcut_2'
android:icon='@drawable/shortcut_2_icon' android:icon='@drawable/shortcut_2_icon'
iconUrl='{{{icon_url}}}'
iconHash='{{{icon_hash}}}' iconHash='{{{icon_hash}}}'
android:shortcutShortLabel='@string/shortcut_2_short_name' android:shortcutShortLabel='@string/shortcut_2_short_name'
android:shortcutLongLabel='@string/shortcut_2_name'> android:shortcutLongLabel='@string/shortcut_2_name'>
...@@ -34,6 +36,7 @@ ...@@ -34,6 +36,7 @@
<shortcut <shortcut
android:shortcutId='shortcut_3' android:shortcutId='shortcut_3'
android:icon='@drawable/shortcut_3_icon' android:icon='@drawable/shortcut_3_icon'
iconUrl='{{{icon_url}}}'
iconHash='{{{icon_hash}}}' iconHash='{{{icon_hash}}}'
android:shortcutShortLabel='@string/shortcut_3_short_name' android:shortcutShortLabel='@string/shortcut_3_short_name'
android:shortcutLongLabel='@string/shortcut_3_name'> android:shortcutLongLabel='@string/shortcut_3_name'>
...@@ -49,6 +52,7 @@ ...@@ -49,6 +52,7 @@
<shortcut <shortcut
android:shortcutId='shortcut_4' android:shortcutId='shortcut_4'
android:icon='@drawable/shortcut_4_icon' android:icon='@drawable/shortcut_4_icon'
iconUrl='{{{icon_url}}}'
iconHash='{{{icon_hash}}}' iconHash='{{{icon_hash}}}'
android:shortcutShortLabel='@string/shortcut_4_short_name' android:shortcutShortLabel='@string/shortcut_4_short_name'
android:shortcutLongLabel='@string/shortcut_4_name'> android:shortcutLongLabel='@string/shortcut_4_name'>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment