Bug 1405021 - Use web app origin as default scope r=droeh
MozReview-Commit-ID: EwxR6mQITmy
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppManifest.java
+++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppManifest.java
@@ -168,31 +168,38 @@ public class WebAppManifest {
final LoadFaviconResult loadIconResult = FaviconDecoder
.decodeDataURI(GeckoAppShell.getApplicationContext(), iconStr);
if (loadIconResult == null) {
return null;
}
return loadIconResult.getBestBitmap(GeckoAppShell.getPreferredIconSize());
}
+ private static Uri stripPath(final Uri uri) {
+ return new Uri.Builder()
+ .scheme(uri.getScheme())
+ .authority(uri.getAuthority())
+ .build();
+ }
+
private static Uri stripLastPathSegment(final Uri uri) {
final Uri.Builder builder = new Uri.Builder()
.scheme(uri.getScheme())
.authority(uri.getAuthority());
final List<String> segments = uri.getPathSegments();
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 Uri defaultScope = stripPath(mStartUri);
final String scopeStr = manifest.optString("scope", null);
if (scopeStr == null) {
return defaultScope;
}
Uri scope = Uri.parse(scopeStr);
if (scope == null) {
return defaultScope;