Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java |
| index 1874d797bbd8038aae8ef85434f2ababc50207ad..ceb153b7dfee1ec387283daeecc82a40a59631df 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java |
| @@ -7,11 +7,13 @@ package org.chromium.chrome.browser.webapps; |
| import android.graphics.Bitmap; |
| import android.text.TextUtils; |
| -import org.chromium.base.Log; |
| +import org.chromium.base.CollectionUtil; |
| import org.chromium.chrome.browser.ShortcutHelper; |
| import org.chromium.chrome.browser.tab.Tab; |
| import org.chromium.chrome.browser.util.UrlUtilities; |
| +import java.util.Set; |
| + |
| /** |
| * This class checks whether the WebAPK needs to be re-installed and sends a request to re-install |
| * the WebAPK if it needs to be re-installed. |
| @@ -51,13 +53,14 @@ public class ManifestUpgradeDetector implements ManifestUpgradeDetectorFetcher.C |
| public String scopeUrl; |
| public String name; |
| public String shortName; |
| - public String iconUrl; |
| + public String bestIconUrl; |
| // Hash of untransformed icon bytes. The hash should have been taken prior to any |
| // encoding/decoding. |
| - public String iconMurmur2Hash; |
| + public String bestIconMurmur2Hash; |
| - public Bitmap icon; |
| + public Bitmap bestIcon; |
| + public Set<String> iconUrls; |
|
dominickn
2016/11/17 02:34:38
Why does this need to be a set? It looks like it's
Xi Han
2016/11/17 18:09:58
It is because the order of the URLs doesn't matter
dominickn
2016/11/17 18:50:53
But we're not doing a comparison with this anymore
Xi Han
2016/11/17 20:42:37
Done.
|
| public int displayMode; |
| public int orientation; |
| public long themeColor; |
| @@ -131,8 +134,9 @@ public class ManifestUpgradeDetector implements ManifestUpgradeDetectorFetcher.C |
| */ |
| @Override |
| public void onGotManifestData(String startUrl, String scopeUrl, String name, String shortName, |
| - String iconUrl, String iconMurmur2Hash, Bitmap iconBitmap, int displayMode, |
| - int orientation, long themeColor, long backgroundColor) { |
| + String bestIconUrl, String bestIconMurmur2Hash, Bitmap bestIconBitmap, |
| + String[] iconUrls, int displayMode, int orientation, long themeColor, |
| + long backgroundColor) { |
| mFetcher.destroy(); |
| mFetcher = null; |
| @@ -145,9 +149,10 @@ public class ManifestUpgradeDetector implements ManifestUpgradeDetectorFetcher.C |
| fetchedData.scopeUrl = scopeUrl; |
| fetchedData.name = name; |
| fetchedData.shortName = shortName; |
| - fetchedData.iconUrl = iconUrl; |
| - fetchedData.iconMurmur2Hash = iconMurmur2Hash; |
| - fetchedData.icon = iconBitmap; |
| + fetchedData.bestIconUrl = bestIconUrl; |
| + fetchedData.bestIconMurmur2Hash = bestIconMurmur2Hash; |
| + fetchedData.bestIcon = bestIconBitmap; |
| + fetchedData.iconUrls = CollectionUtil.newHashSet(iconUrls); |
| fetchedData.displayMode = displayMode; |
| fetchedData.orientation = orientation; |
| fetchedData.themeColor = themeColor; |
| @@ -163,35 +168,23 @@ public class ManifestUpgradeDetector implements ManifestUpgradeDetectorFetcher.C |
| * Checks whether the WebAPK needs to be upgraded provided the fetched manifest data. |
| */ |
| private boolean needsUpgrade(FetchedManifestData fetchedData) { |
| - if (!urlsMatchIgnoringFragments(mMetaData.iconUrl, fetchedData.iconUrl) |
| - || !mMetaData.iconMurmur2Hash.equals(fetchedData.iconMurmur2Hash)) { |
| - return true; |
| - } |
| - |
| - if (!urlsMatchIgnoringFragments(mMetaData.scope, fetchedData.scopeUrl)) { |
| - // Sometimes the scope doesn't match due to a missing "/" at the end of the scope URL. |
| - // Print log to find such cases. |
| - Log.d(TAG, "Needs to request update since the scope from WebappInfo (%s) doesn't match" |
| - + "the one fetched from Web Manifest(%s).", mMetaData.scope, |
| - fetchedData.scopeUrl); |
| - return true; |
| - } |
| + String metaDataBestIconMurmur2Hash = |
| + mMetaData.iconUrlAndIconMurmur2HashMap.get(fetchedData.bestIconUrl); |
| - if (!urlsMatchIgnoringFragments(mMetaData.startUrl, fetchedData.startUrl) |
| + return !TextUtils.equals(metaDataBestIconMurmur2Hash, fetchedData.bestIconMurmur2Hash) |
| + || !mMetaData.iconUrlAndIconMurmur2HashMap.keySet().equals(fetchedData.iconUrls) |
| + || !urlsMatchIgnoringFragments(mMetaData.scope, fetchedData.scopeUrl) |
| + || !urlsMatchIgnoringFragments(mMetaData.startUrl, fetchedData.startUrl) |
| || !TextUtils.equals(mMetaData.shortName, fetchedData.shortName) |
| || !TextUtils.equals(mMetaData.name, fetchedData.name) |
| || mMetaData.backgroundColor != fetchedData.backgroundColor |
| || mMetaData.themeColor != fetchedData.themeColor |
| || mMetaData.orientation != fetchedData.orientation |
| - || mMetaData.displayMode != fetchedData.displayMode) { |
| - return true; |
| - } |
| - |
| - return false; |
| + || mMetaData.displayMode != fetchedData.displayMode; |
| } |
| /** |
| - * Returns whether the urls match ignoring fragments. Canonicalizes the URLs prior to doing the |
| + * Returns whether the URLs match ignoring fragments. Canonicalizes the URLs prior to doing the |
| * comparison. |
| */ |
| protected boolean urlsMatchIgnoringFragments(String url1, String url2) { |