Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java |
| index 8aacf80f512fd19202852de68ff89a67204ab4a7..0c32290179041cbcca8a9381445bbbfcaccb9980 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java |
| @@ -18,6 +18,7 @@ import org.chromium.chrome.browser.ChromeSwitches; |
| import org.chromium.chrome.browser.tab.Tab; |
| import org.chromium.webapk.lib.client.WebApkVersion; |
| +import java.util.Set; |
| import java.util.concurrent.TimeUnit; |
| /** |
| @@ -112,13 +113,13 @@ public class WebApkUpdateManager implements ManifestUpgradeDetector.Callback { |
| recordUpdate(storage, false); |
| if (info != null) { |
| - updateAsync(info, bestIconUrl); |
| + updateAsync(info, bestIconUrl, false); |
| return; |
| } |
| // Since we could not fetch the Web Manifest, we do not know what the best icon URL is. Pass |
| // an empty "best icon URL" to tell the server that there is no best icon URL. |
| - updateAsync(mInfo, ""); |
| + updateAsync(mInfo, "", true); |
| } |
| /** |
| @@ -131,14 +132,24 @@ public class WebApkUpdateManager implements ManifestUpgradeDetector.Callback { |
| /** |
| * Sends request to WebAPK Server to update WebAPK. |
| */ |
| - protected void updateAsync(WebApkInfo info, String bestIconUrl) { |
| + protected void updateAsync(WebApkInfo info, String bestIconUrl, boolean staleManifest) { |
| int versionCode = readVersionCodeFromAndroidManifest(info.webApkPackageName()); |
| String bestIconMurmur2Hash = info.iconUrlToMurmur2HashMap().get(bestIconUrl); |
| + Set<String> iconUrlSet = info.iconUrlToMurmur2HashMap().keySet(); |
| + String[] iconUrls = iconUrlSet.toArray(new String[iconUrlSet.size()]); |
| + String[] iconHashs = null; |
| + if (staleManifest) { |
| + bestIconMurmur2Hash = ""; |
| + iconHashs = new String[iconUrls.length]; |
| + for (int i = 0; i < iconUrls.length; ++i) { |
| + iconHashs[i] = info.iconUrlToMurmur2HashMap().get(iconUrls[i]); |
| + } |
| + } |
| nativeUpdateAsync(info.id(), info.manifestStartUrl(), info.scopeUri().toString(), |
| info.name(), info.shortName(), bestIconUrl, bestIconMurmur2Hash, info.icon(), |
| - info.iconUrlToMurmur2HashMap().keySet().toArray(new String[0]), info.displayMode(), |
| - info.orientation(), info.themeColor(), info.backgroundColor(), info.manifestUrl(), |
| - info.webApkPackageName(), versionCode); |
| + iconUrls, iconHashs, info.displayMode(), info.orientation(), info.themeColor(), |
| + info.backgroundColor(), info.manifestUrl(), info.webApkPackageName(), versionCode, |
| + staleManifest); |
| } |
| /** |
| @@ -264,6 +275,7 @@ public class WebApkUpdateManager implements ManifestUpgradeDetector.Callback { |
| private static native void nativeUpdateAsync(String id, String startUrl, String scope, |
| String name, String shortName, String bestIconUrl, String bestIconMurmur2Hash, |
|
pkotwicz
2016/12/06 17:53:37
Can we remove the |bestIconMurmur2Hash| completely
Xi Han
2016/12/07 19:42:51
Good point. Removed.
|
| - Bitmap bestIcon, String[] iconUrls, int displayMode, int orientation, long themeColor, |
| - long backgroundColor, String manifestUrl, String webApkPackage, int webApkVersion); |
| + Bitmap bestIcon, String[] iconUrls, String[] iconHashes, int displayMode, |
| + int orientation, long themeColor, long backgroundColor, String manifestUrl, |
| + String webApkPackage, int webApkVersion, boolean staleManifest); |
| } |