Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1501)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java

Issue 2453423002: Send all of the icon URLs listed in Web Manifest to WebAPK Server. (Closed)
Patch Set: Remove best_icon_url and best_icon_hash from metadata, but add all icon urls and icon hashs in. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..491089caa1c09cff85271178243ef406845ac6e7 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,15 @@ package org.chromium.chrome.browser.webapps;
import android.graphics.Bitmap;
import android.text.TextUtils;
+import org.chromium.base.CollectionUtil;
import org.chromium.base.Log;
import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.util.UrlUtilities;
+import java.util.Arrays;
+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 +55,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;
public int displayMode;
public int orientation;
public long themeColor;
@@ -131,8 +136,8 @@ 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 iconBitmap, String[] iconUrls,
+ int displayMode, int orientation, long themeColor, long backgroundColor) {
mFetcher.destroy();
mFetcher = null;
@@ -145,9 +150,13 @@ 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 = iconBitmap;
+ fetchedData.iconUrls = CollectionUtil.newHashSet();
pkotwicz 2016/11/11 21:04:18 - In which scenario is iconUrls null? - Sorry I sh
Xi Han 2016/11/14 19:36:09 I did try this, but eclipse gave an error to me la
+ if (iconUrls != null) {
+ fetchedData.iconUrls.addAll(Arrays.asList(iconUrls));
+ }
fetchedData.displayMode = displayMode;
fetchedData.orientation = orientation;
fetchedData.themeColor = themeColor;
@@ -163,8 +172,11 @@ public class ManifestUpgradeDetector implements ManifestUpgradeDetectorFetcher.C
* Checks whether the WebAPK needs to be upgraded provided the fetched manifest data.
*/
private boolean needsUpgrade(FetchedManifestData fetchedData) {
pkotwicz 2016/11/11 21:04:18 Can we simplify this function return !mMetaData.i
Xi Han 2016/11/14 19:36:09 Done.
- if (!urlsMatchIgnoringFragments(mMetaData.iconUrl, fetchedData.iconUrl)
- || !mMetaData.iconMurmur2Hash.equals(fetchedData.iconMurmur2Hash)) {
+ if (!mMetaData.iconURLAndHashMap.containsKey(fetchedData.bestIconUrl)) return true;
+
+ String cachedBestIconMurmur2Hash =
+ mMetaData.iconURLAndHashMap.get(fetchedData.bestIconUrl);
+ if (!cachedBestIconMurmur2Hash.equals(fetchedData.bestIconMurmur2Hash)) {
return true;
}
@@ -183,7 +195,8 @@ public class ManifestUpgradeDetector implements ManifestUpgradeDetectorFetcher.C
|| mMetaData.backgroundColor != fetchedData.backgroundColor
|| mMetaData.themeColor != fetchedData.themeColor
|| mMetaData.orientation != fetchedData.orientation
- || mMetaData.displayMode != fetchedData.displayMode) {
+ || mMetaData.displayMode != fetchedData.displayMode
+ || !mMetaData.iconURLAndHashMap.keySet().equals(fetchedData.iconUrls)) {
pkotwicz 2016/11/11 21:04:18 Nit: Maybe iconUrlAndMurmur2HashMap() - https://g
Xi Han 2016/11/14 19:36:09 Done.
return true;
}

Powered by Google App Engine
This is Rietveld 408576698