Closed Bug 1389236 Opened 7 years ago Closed 7 years ago

Open external links in PWAs in a Custom Tab

Categories

(Firefox for Android Graveyard :: Web Apps (PWAs), enhancement)

enhancement
Not set
normal

Tracking

(firefox57 fixed, firefox58 verified)

VERIFIED FIXED
Firefox 57
Tracking Status
firefox57 --- fixed
firefox58 --- verified

People

(Reporter: snorp, Assigned: esawin)

References

Details

Attachments

(4 files, 2 obsolete files)

Instead of doing a mini-browser as in bug 1388747, product has requested we simply kick out to a custom tab, since that's pretty much what you'd expect in a native app as well.
Eugen, this might be the next thing to tackle, as discussed. We'll need to not only handle target=_blank stuff, but also links that are in the same window.
Assignee: nobody → esawin
Depends on: 1377580
Wait for the callback result for each URI loading request.
The result is boolean for now. The handler returns true if the request has been handled, false if Gecko should handle it instead. In the latter case, GeckoView decided on how to handle it.

I've also simplified the "where" argument, possible target windows are now DEFAULT, CURRENT and NEW, removing NEWTAB and SWITCHTAB which are specific to Fennec.
Attachment #8897007 - Flags: review?(snorp)
Custom tabs always return true since we always handle the event.
Attachment #8897008 - Flags: review?(snorp)
PWAs launch a custom tabs intent for URIs not in their scope.
This will fire the generic custom tabs intent.
Attachment #8897009 - Flags: review?(snorp)
Fixed syntax error.
Attachment #8897007 - Attachment is obsolete: true
Attachment #8897007 - Flags: review?(snorp)
Attachment #8897123 - Flags: review?(snorp)
Attachment #8897008 - Flags: review?(snorp) → review+
Attachment #8897123 - Flags: review?(snorp) → review+
Comment on attachment 8897009 [details] [diff] [review]
0003-Bug-1389236-3.0-Launch-a-custom-tabs-intent-for-out-.patch

Review of attachment 8897009 [details] [diff] [review]:
-----------------------------------------------------------------

::: mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
@@ +270,4 @@
>          if (isInScope(uri)) {
>              view.loadUri(uri);
>          } else {
> +            CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();

I think we should use the theme_color from the manifest as the toolbar color.

@@ +271,5 @@
>              view.loadUri(uri);
>          } else {
> +            CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
> +            CustomTabsIntent intent = builder.build();
> +            intent.launchUrl(this, Uri.parse(uri));

I think we may need to do our own thing here to ensure that we launch into our own Custom Tab implementation and not whatever it chooses. Maybe it's enough to set the class on the CustomTabsIntent.intent instance?
Attachment #8897009 - Flags: review?(snorp) → review-
Attachment #8897010 - Flags: review?(snorp) → review+
Launch our custom tabs activity for out-of-scope URI load requests.
Attachment #8897009 - Attachment is obsolete: true
Attachment #8898840 - Flags: review?(snorp)
Comment on attachment 8898840 [details] [diff] [review]
0003-Bug-1389236-3.1-Launch-a-custom-tabs-intent-for-out-.patch

Review of attachment 8898840 [details] [diff] [review]:
-----------------------------------------------------------------

We should set the theme color too, but maybe that can be done in a followup.
Attachment #8898840 - Flags: review?(snorp) → review+
Pushed by esawin@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/1fe42a7f6174
[1.0] Allow sync handling of all URI loading requests in the app. r=snorp
https://hg.mozilla.org/integration/mozilla-inbound/rev/8013338c457c
[2.0] Mark URI-loading requests in the custom tabs handler as handled. r=snorp
https://hg.mozilla.org/integration/mozilla-inbound/rev/dac0b47a5734
[3.1] Launch a custom tabs intent for out-of-scope URIs in the PWA's onLoadUri handler. r=snorp
https://hg.mozilla.org/integration/mozilla-inbound/rev/8ee92d119955
[4.0] Mark URI-loading requests in the GeckoView example app handler as handled. r=snorp
>  We'll need to not only handle target=_blank stuff, but also links that are in the same window.

Yep, essentially, we want links that are outside of the PWA scope to open in a custom tab.

> I think we should use the theme_color from the manifest as the toolbar color.

That seems indeed like a good idea. To be clear: we want to use the theme_color asset defined in the manifest of the installed PWA, and not the theme color defined in the <meta> section or manifest of the site loaded in the custom tab.
Verified as fixed on Nightly 58 (2017-09-22).
Devices:
Prestigio Grace X5 (Android 4.4.2)
LG G4 (Android 5.1)
Huawei Honor 8 (Android 6.0)
Asus ZenPad 8.0 Z380KL (Android 6.0.1)
Status: RESOLVED → VERIFIED
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: