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

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: Nits. 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e324b3e08f429b65436837cf94345d9f17947873 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
@@ -4,13 +4,11 @@
package org.chromium.chrome.browser.webapps;
-import android.graphics.Bitmap;
import android.text.TextUtils;
-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 org.chromium.chrome.browser.webapps.ManifestUpgradeDetectorFetcher.FetchedManifestData;
/**
* This class checks whether the WebAPK needs to be re-installed and sends a request to re-install
@@ -43,27 +41,6 @@ public class ManifestUpgradeDetector implements ManifestUpgradeDetectorFetcher.C
private static final String TAG = "cr_UpgradeDetector";
- /**
- * Fetched Web Manifest data.
- */
- public static class FetchedManifestData {
- public String startUrl;
- public String scopeUrl;
- public String name;
- public String shortName;
- public String iconUrl;
-
- // Hash of untransformed icon bytes. The hash should have been taken prior to any
- // encoding/decoding.
- public String iconMurmur2Hash;
-
- public Bitmap icon;
- public int displayMode;
- public int orientation;
- public long themeColor;
- public long backgroundColor;
- }
-
/** The WebAPK's tab. */
private final Tab mTab;
@@ -130,29 +107,10 @@ public class ManifestUpgradeDetector implements ManifestUpgradeDetectorFetcher.C
* Called when the updated Web Manifest has been fetched.
*/
@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) {
+ public void onGotManifestData(FetchedManifestData fetchedData) {
mFetcher.destroy();
mFetcher = null;
- if (TextUtils.isEmpty(scopeUrl)) {
- scopeUrl = ShortcutHelper.getScopeFromUrl(startUrl);
- }
-
- FetchedManifestData fetchedData = new FetchedManifestData();
- fetchedData.startUrl = startUrl;
- fetchedData.scopeUrl = scopeUrl;
- fetchedData.name = name;
- fetchedData.shortName = shortName;
- fetchedData.iconUrl = iconUrl;
- fetchedData.iconMurmur2Hash = iconMurmur2Hash;
- fetchedData.icon = iconBitmap;
- fetchedData.displayMode = displayMode;
- fetchedData.orientation = orientation;
- fetchedData.themeColor = themeColor;
- fetchedData.backgroundColor = backgroundColor;
-
// TODO(hanxi): crbug.com/627824. Validate whether the new fetched data is
// WebAPK-compatible.
boolean upgrade = needsUpgrade(fetchedData);
@@ -163,35 +121,22 @@ 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)
+ || !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) {
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698