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

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

Issue 2341163002: Canonicalize URLs prior to comparing in ManifestUpgradeDetector (Closed)
Patch Set: Merge branch 'master' into url_canonicalize Created 4 years, 3 months 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_sources.gni » ('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 a0ffd9e2078f833088572265ee2d76ce3b46dd2c..c95dcbafbbf93c0712685a7e71a78be8bfcc55c0 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
@@ -12,6 +12,7 @@ import org.chromium.base.Log;
import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.util.IntentUtils;
+import org.chromium.chrome.browser.util.UrlUtilities;
import org.chromium.webapk.lib.common.WebApkMetaDataKeys;
/**
@@ -23,7 +24,7 @@ public class ManifestUpgradeDetector implements ManifestUpgradeDetectorFetcher.C
* Called when the process of checking Web Manifest update is complete.
*/
public interface Callback {
- public void onUpgradeNeededCheckFinished(boolean isUpgraded, FetchedManifestData data);
+ public void onUpgradeNeededCheckFinished(boolean needsUpgrade, FetchedManifestData data);
}
private static final String TAG = "cr_UpgradeDetector";
@@ -178,21 +179,20 @@ public class ManifestUpgradeDetector implements ManifestUpgradeDetectorFetcher.C
// TODO(hanxi): crbug.com/627824. Validate whether the new fetched data is
// WebAPK-compatible.
- boolean upgradeRequired = requireUpgrade(fetchedData);
- mCallback.onUpgradeNeededCheckFinished(upgradeRequired, fetchedData);
+ boolean upgrade = needsUpgrade(fetchedData);
+ mCallback.onUpgradeNeededCheckFinished(upgrade, fetchedData);
}
/**
* Checks whether the WebAPK needs to be upgraded provided the fetched manifest data.
*/
- private boolean requireUpgrade(FetchedManifestData fetchedData) {
- if (!TextUtils.equals(mIconUrl, fetchedData.iconUrl)
+ private boolean needsUpgrade(FetchedManifestData fetchedData) {
+ if (!urlsMatchIgnoringFragments(mIconUrl, fetchedData.iconUrl)
|| !mIconMurmur2Hash.equals(fetchedData.iconMurmur2Hash)) {
return true;
}
- boolean scopeMatch = mWebappInfo.scopeUri().toString().equals(fetchedData.scopeUrl);
- if (!scopeMatch) {
+ if (!urlsMatchIgnoringFragments(mWebappInfo.scopeUri().toString(), 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"
@@ -201,7 +201,7 @@ public class ManifestUpgradeDetector implements ManifestUpgradeDetectorFetcher.C
return true;
}
- if (!TextUtils.equals(mStartUrl, fetchedData.startUrl)
+ if (!urlsMatchIgnoringFragments(mStartUrl, fetchedData.startUrl)
|| !TextUtils.equals(mWebappInfo.shortName(), fetchedData.shortName)
|| !TextUtils.equals(mWebappInfo.name(), fetchedData.name)
|| mWebappInfo.backgroundColor() != fetchedData.backgroundColor
@@ -213,4 +213,12 @@ public class ManifestUpgradeDetector implements ManifestUpgradeDetectorFetcher.C
return false;
}
+
+ /**
+ * Returns whether the urls match ignoring fragments. Canonicalizes the URLs prior to doing the
+ * comparison.
+ */
+ protected boolean urlsMatchIgnoringFragments(String url1, String url2) {
+ return UrlUtilities.urlsMatchIgnoringFragments(url1, url2);
+ }
}
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698