Closed Bug 1815739 Opened 3 years ago Closed 2 years ago

Support using Firefox as default PDF reader on Android

Categories

(Firefox for Android :: General, enhancement, P1)

All
Android
enhancement

Tracking

()

RESOLVED FIXED
121 Branch
Tracking Status
relnote-firefox --- -
firefox120 --- wontfix
firefox121 --- fixed

People

(Reporter: marco, Assigned: calixte)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Attachments

(1 file)

Once we have enabled the reader by default on Android and if we are satisfied with the performance, we should evaluate setting ourselves as default reader on Android.

Severity: -- → N/A

The first step should be to at least allow users to do it manually.

I tested locally with a modified:
https://github.com/mozilla-mobile/firefox-android/blob/main/fenix/app/src/main/AndroidManifest.xml
to handle pdfs.

Fenix is correctly proposed to open a pdf but then urls like content://media/external_primary/downloads... or content://com.android.providers.downloads.documents/document/msf%3A1000000018 are passed to Fenix which doesn't seem to be able to read them.
So I suppose that a first good step would be to make Fenix supports such a scheme.

Depends on: 1806171

:csadilek, would it be possible to only allow content://... for pdf files ?

Flags: needinfo?(csadilek)

Unfortunately, I don't think so. We need to address bug 1684947 first. Otherwise, we'd open ourselves up for data leaks, see also https://bugzilla.mozilla.org/show_bug.cgi?id=1684761#c13 for more details e.g., a file with a pdf extension could still link to an internal file.

Currently content, resources, and file are blocked for directs loads in Fenix.

Flags: needinfo?(csadilek)

Do we have internal files that are PDFs?

Hi :marco,

My concern is more: How would we make sure it is really a PDF we're loading and bypassing the rule for? And it's not e.g., a symbolic link to an internal file the user was tricked into creating via a different application?

I think we cannot simply make the decision based on the file extension. So this would need more investigation, ideally addressing bug 1684947 first.

I'm not an Android stuff expert, but as far as I understand, nowadays shared uris should use a content scheme rather than a file one.
So if the ContentProvider is trusted, I suppose we can consider those uris as safe.
I think we shouldn't handle file uris.
Considering https://developer.android.com/topic/security/risks/content-resolver, the minimal mitigation we could do is to have a whitelist with the authorities we want to allow to provide some data to Fenix (for example com.android.providers.downloads for the app managing the downloads).
Anyway, I've a patch for handling uris with a content scheme, I'll submit it and we could then iterate to see how make it safe enough.

Assignee: nobody → cdenizet
Status: NEW → ASSIGNED

On Android, contents are shared in using uris with a content scheme, hence this patch
adds a new protocol handler for 'content:\', a new type of input stream in order to read
them and a new type of channel.

whitelist with the authorities we want to allow

If file manager apps are to be included, maybe the whitelist should include com.android.documentsui?

Flags: needinfo?(cdenizet)
Blocks: 1809149
Blocks: 1832519

Can the PDF viewer be completely separated from the main app? As in, opening a PDF link in Fenix would start a separate 'PDF Viewer' activity instead of simply opening a new tab, and you could switch between the two via the Recent Apps switcher.

What I'm envisioning is that opening a local PDF in Fenix would open the PDF Viewer activity only, without starting the main browser. I've seen this behaviour in the Google Drive app's PDF viewer, where any PDF would open near instantly in a separate activity (com.google.android.apps.viewer.PdfViewerActivity), while the main Drive app itself (com.google.android.apps.docs) was quite slow to load.

Instead of waiting for the whole browser (and extensions) to fire up, just launching pdf.js as a separate activity would be faster, and eat much less RAM, too.

Bug 1813251 is a duplicate of this bug.

Duplicate of this bug: 1813251

Release Note Request (optional, but appreciated)
[Why is this notable]: Users will be able to use Firefox as default PDF reader.
[Affects Firefox for Android]: Yes, exclusively Firefox for Android.
[Suggested wording]: Firefox can now be used as default PDF reader.
[Links (documentation, blog post, etc)]: N/A

relnote-firefox: --- → ?

maybe "Firefox can now be set as a primary PDF viewer." for the release notes?

(In reply to Marco Castelluccio [:marco] from comment #13)

Release Note Request (optional, but appreciated)
[Why is this notable]: Users will be able to use Firefox as default PDF reader.
[Affects Firefox for Android]: Yes, exclusively Firefox for Android.
[Suggested wording]: Firefox can now be used as default PDF reader.
[Links (documentation, blog post, etc)]: N/A

I'm confused about this comment. Has this bug actually been fixed (I've seen no meaningful activity over the last few months)? Or should I hold my joy because you're just preparing what should be written in the release notes when (and if… 😢) this bug is eventually fixed?

We are preparing for when the bug is eventually fixed, but we are planning to fix this very soon (you can see activity in the Phabricator revision that is attached to this bug).

Priority: -- → P1
Pushed by cdenizet@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/22970015ff0c Add a protocol handler for content uris in GV r=geckoview-reviewers,owlish,tthibaud,necko-reviewers,kershaw

Backed out for causing saveAContentPdfDocument related junit failures.

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-FAIL | org.mozilla.geckoview.test.PdfCreationTest#saveAContentPdfDocument | org.mozilla.geckoview.test.rule.GeckoSessionTestRule$ChildCrashedException: Child process crashed
Blocks: 1864622
Pushed by cdenizet@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/61e622def2f6 Add a protocol handler for content uris in GV r=geckoview-reviewers,owlish,tthibaud,necko-reviewers,kershaw
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 121 Branch

Added to the Fx121 relnotes.

Flags: needinfo?(cdenizet)
Blocks: 1864956

Looks like bug 1864956 is going to be shipping in 122 instead.

No longer blocks: 1864956
Blocks: 1864956
See Also: → 1869126
Regressions: 1869250
No longer regressions: 1869250
See Also: → 1875173
Regressions: 1888978
Duplicate of this bug: 1516467
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: