Bug 1401208 - Change default web app scope to the start_url r=esawin
MozReview-Commit-ID: Jvbru5oRYDH
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppManifest.java
+++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppManifest.java
@@ -100,18 +100,18 @@ public class WebAppManifest {
public String getOrientation() {
return mOrientation;
}
private void readManifest(final JSONObject manifest, final JSONObject manifestField) {
mThemeColor = readThemeColor(manifestField);
mName = readName(manifestField);
mIcon = readIcon(manifest);
+ mStartUri = readStartUrl(manifestField);
mScope = readScope(manifestField);
- mStartUri = readStartUrl(manifestField);
mDisplayMode = manifestField.optString("display", null);
mOrientation = manifestField.optString("orientation", null);
}
private Integer readThemeColor(final JSONObject manifest) {
final String colorStr = manifest.optString("theme_color", null);
if (colorStr != null) {
@@ -182,24 +182,25 @@ public class WebAppManifest {
for (int i = 0; i < (segments.size() - 1); i++) {
builder.appendPath(segments.get(i));
}
return builder.build();
}
private Uri readScope(final JSONObject manifest) {
+ final Uri defaultScope = stripLastPathSegment(mStartUri);
final String scopeStr = manifest.optString("scope", null);
if (scopeStr == null) {
- return null;
+ return defaultScope;
}
Uri scope = Uri.parse(scopeStr);
if (scope == null) {
- return null;
+ return defaultScope;
}
if (scope.isRelative()) {
scope = buildRelativeUrl(stripLastPathSegment(mManifestUri), scope);
}
return scope;
}