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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInfo.java

Issue 2956193002: [Android] Enable WebAPK to have multiple intent filters (Closed)
Patch Set: Merge branch 'mustache' into rewriting Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.webapps; 5 package org.chromium.chrome.browser.webapps;
6 6
7 import android.content.Intent; 7 import android.content.Intent;
8 import android.content.pm.ApplicationInfo; 8 import android.content.pm.ApplicationInfo;
9 import android.content.pm.PackageManager; 9 import android.content.pm.PackageManager;
10 import android.content.res.Resources; 10 import android.content.res.Resources;
11 import android.graphics.Bitmap; 11 import android.graphics.Bitmap;
12 import android.graphics.BitmapFactory; 12 import android.graphics.BitmapFactory;
13 import android.net.Uri;
13 import android.os.Bundle; 14 import android.os.Bundle;
14 import android.text.TextUtils; 15 import android.text.TextUtils;
15 16
16 import org.chromium.base.ContextUtils; 17 import org.chromium.base.ContextUtils;
17 import org.chromium.base.Log; 18 import org.chromium.base.Log;
18 import org.chromium.blink_public.platform.WebDisplayMode; 19 import org.chromium.blink_public.platform.WebDisplayMode;
19 import org.chromium.chrome.browser.ShortcutHelper; 20 import org.chromium.chrome.browser.ShortcutHelper;
20 import org.chromium.chrome.browser.util.IntentUtils; 21 import org.chromium.chrome.browser.util.IntentUtils;
21 import org.chromium.content_public.common.ScreenOrientationValues; 22 import org.chromium.content_public.common.ScreenOrientationValues;
22 import org.chromium.webapk.lib.common.WebApkConstants; 23 import org.chromium.webapk.lib.common.WebApkConstants;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 return null; 180 return null;
180 } 181 }
181 182
182 // The default scope should be computed from the Web Manifest start URL. If the WebAPK was 183 // The default scope should be computed from the Web Manifest start URL. If the WebAPK was
183 // launched from a deep link {@link startUrl} may be different from the Web Manifest start 184 // launched from a deep link {@link startUrl} may be different from the Web Manifest start
184 // URL. 185 // URL.
185 if (TextUtils.isEmpty(scope)) { 186 if (TextUtils.isEmpty(scope)) {
186 scope = ShortcutHelper.getScopeFromUrl(manifestStartUrl); 187 scope = ShortcutHelper.getScopeFromUrl(manifestStartUrl);
187 } 188 }
188 189
190 // The WebAPK may have been launched as a result of an intent filter for a different scheme
191 // or top level domain. Rewrite the scheme and host name to the scope's scheme and host
192 // name.
palmer 2017/06/28 21:24:40 This is where the rubber hits the road, right? How
pkotwicz 2017/06/28 22:26:21 I think that Yaron was asking whether doing the UR
Yaron 2017/06/29 02:15:07 Yes, that was one part. It sounds like it's safe.
Yaron 2017/07/10 23:39:35 So playing this out - what happens if you're in a
pkotwicz 2017/07/11 14:31:38 The goal of the URL rewriting is to enable a web a
Yaron 2017/07/12 16:54:01 Not sure that's really desirable.
193 Uri parsedUrl = Uri.parse(url);
194 Uri parsedScope = Uri.parse(scope);
195 url = parsedUrl.buildUpon()
196 .scheme(parsedScope.getScheme())
197 .authority(parsedScope.getAuthority())
198 .build()
199 .toString();
200
189 return new WebApkInfo(id, url, forceNavigation, scope, primaryIcon, badg eIcon, name, 201 return new WebApkInfo(id, url, forceNavigation, scope, primaryIcon, badg eIcon, name,
190 shortName, displayMode, orientation, source, themeColor, backgro undColor, 202 shortName, displayMode, orientation, source, themeColor, backgro undColor,
191 webApkPackageName, shellApkVersion, manifestUrl, manifestStartUr l, 203 webApkPackageName, shellApkVersion, manifestUrl, manifestStartUr l,
192 iconUrlToMurmur2HashMap); 204 iconUrlToMurmur2HashMap);
193 } 205 }
194 206
195 protected WebApkInfo(String id, String url, boolean forceNavigation, String scope, 207 protected WebApkInfo(String id, String url, boolean forceNavigation, String scope,
196 Icon primaryIcon, Icon badgeIcon, String name, String shortName, int displayMode, 208 Icon primaryIcon, Icon badgeIcon, String name, String shortName, int displayMode,
197 int orientation, int source, long themeColor, long backgroundColor, 209 int orientation, int source, long themeColor, long backgroundColor,
198 String webApkPackageName, int shellApkVersion, String manifestUrl, 210 String webApkPackageName, int shellApkVersion, String manifestUrl,
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return ScreenOrientationValues.PORTRAIT; 415 return ScreenOrientationValues.PORTRAIT;
404 } else if (orientation.equals("portrait-primary")) { 416 } else if (orientation.equals("portrait-primary")) {
405 return ScreenOrientationValues.PORTRAIT_PRIMARY; 417 return ScreenOrientationValues.PORTRAIT_PRIMARY;
406 } else if (orientation.equals("portrait-secondary")) { 418 } else if (orientation.equals("portrait-secondary")) {
407 return ScreenOrientationValues.PORTRAIT_SECONDARY; 419 return ScreenOrientationValues.PORTRAIT_SECONDARY;
408 } else { 420 } else {
409 return ScreenOrientationValues.DEFAULT; 421 return ScreenOrientationValues.DEFAULT;
410 } 422 }
411 } 423 }
412 } 424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698