Closed Bug 1638156 Opened 5 years ago Closed 5 years ago

Support key modifiers to open downloaded PDFs in a new window, background tab

Categories

(Firefox :: Downloads Panel, defect, P2)

defect

Tracking

()

RESOLVED FIXED
Firefox 78
Tracking Status
firefox78 --- fixed

People

(Reporter: sfoster, Assigned: sfoster)

References

(Depends on 2 open bugs)

Details

(Whiteboard: [fxgrowth] )

Attachments

(2 files)

It should be possible to hold click/shift/meta keys when opening a downloaded PDF and if that results in opening the file in the browser, we should follow the normal conventions and open it as appropriate:

  • (default): open in a new tab ("current") open in current tab
  • ctrl/metaKey: open in new tab ("tab")
  • shiftKey: open in new browser window ("window")
  • ctrl/metaKey + shiftKey: open in background tab ("tabshifted")

Do you have suggestions for how to get at the event to check .shiftKey/.ctrlKey/.metaKey when handling the OPEN_DOWNLOAD_FILE action in DownloadManager.jsm for the download cards about:newtab? In the other downloads views for this bug I'm calling BrowserWindowTracker.getTopWindow().whereToOpenLink(event, false, true) to allow use of key modifiers to direct where to open the download if we load it into the browser as a file: URI (e.g. new window, background tab).

Flags: needinfo?(edilee)

(In reply to Ed Lee :Mardak from comment #3)

Probably similar pattern for OPEN_LINK passing a fake event along with the action to determine where to open the link:

https://searchfox.org/mozilla-central/rev/9193635dca8cfdcb68f114306194ffc860456044/browser/components/newtab/content-src/components/Card/Card.jsx#149,152-154
https://searchfox.org/mozilla-central/rev/9193635dca8cfdcb68f114306194ffc860456044/browser/components/newtab/lib/PlacesFeed.jsm#283,307

That makes sense, but its not so clear how to accomplish the same for the options menu where the OpenFile option currently lives. I'm getting lost trying to figure out where the event exists and how to pass modifier key data down to the option's action at https://searchfox.org/mozilla-central/source/browser/components/newtab/content-src/lib/link-menu-options.js#153 (ReactJs noob here)

Before I spend more time on this, the other question that may be relevant here is why SHOW_DOWNLOAD_FILE (which opens the download directory in the OS' filesystem viewer) the default action for the download cards, when elsewhere in the UI we tend to open/launch the file itself - ie OPEN_DOWNLOAD_FILE. Was there a decision made the showing the containing directory is a better fit somehow for this context? If not, maybe I can change the default to OPEN_DOWNLOAD_FILE at which point the tips in comment #3 should be most of what I need.

Assignee: nobody → sfoster
Status: NEW → ASSIGNED
Flags: needinfo?(edilee)

(In reply to Sam Foster [:sfoster] (he/him) from comment #4)

Was there a decision made the showing the containing directory is a better fit somehow for this context?

It looks like the original UX desire was to open the file:
https://github.com/mozilla/activity-stream/issues/3535#issuecomment-344707481

I believe there was a security concern of having a (special) content page sending a message to the main process to "open <arbitrary file>" although I suppose that surface could be reduced to "open <downloaded file index 1>" or some other downloads-specific identifier to then figure out which file it should open.

Flags: needinfo?(edilee)

(In reply to Sam Foster [:sfoster] (he/him) from comment #4)

I'm getting lost trying to figure out where the event exists and how to pass modifier key data down to the option's action

Ah there's a bunch of indirection going on here… The context menu is controlled by an array of strings where those strings key into the link-menu-options that then dynamically create onClick handlers on the rendered items:
https://searchfox.org/mozilla-central/rev/61fceb7c0729773f544a9656f474e36cd636e5ea/browser/components/newtab/content-src/components/LinkMenu/LinkMenu.jsx#41,53-54

It looks like no menu items have ever needed to use the event object or anything dynamic. I suppose maybe you can define the action of a link menu option to be a function that LinkMenu.jsx decides to call the function to get an action object or just plain pass on the statically declared action object.

Depends on: 1433230

(In reply to Ed Lee :Mardak from comment #5)

I believe there was a security concern of having a (special) content page sending a message to the main process to "open <arbitrary file>" although I suppose that surface could be reduced to "open <downloaded file index 1>" or some other downloads-specific identifier to then figure out which file it should open.

As we ended up implementing this (we send a OPEN_DOWNLOAD_FILE message to the parent process and DownloadManager.jsm calls into DownloadsCommon/DownloadIntegration etc to do the file opening) , but under the options menu, I assume this security concern is resolved, or at least orthogonal to this bug.

Pushed by sfoster@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/da0e27f7f17a Allow key modifiers to determine how/'where' PDFs are opened when possible. r=mak https://hg.mozilla.org/integration/autoland/rev/c5c3da72080f Make open downloaded file the default action in about:newtab download cards, and add key modifiers support. r=Mardak
Severity: -- → S3
Priority: -- → P2

To fix the browser_download_open_with_internal_handler.js failure, I set the default "openWhere" option to DownloadUIHelper.loadFileIn to "tab". All the views will pass "current" by default but it looks like for the URI-loader use-case, "tab" does the right thing.

I found at least part of the issue with the private download / about:downloads test: Bug 1329912. With a workaround in place for that, I can't reproduce this locally on linux anymore. But it looks like https://treeherder.mozilla.org/#/jobs?repo=try&revision=2ea1517cc36a34c3a52f36d72ea4be650ef65a62 still has some failures.

Flags: needinfo?(sfoster)
Depends on: 1641770
Pushed by sfoster@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c5e87e5b6f9f Allow key modifiers to determine how/'where' PDFs are opened when possible. r=mak https://hg.mozilla.org/integration/autoland/rev/8d8372333cb9 Make open downloaded file the default action in about:newtab download cards, and add key modifiers support. r=Mardak
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 78
Regressions: 1642431

The support key modifiers to open downloaded PDFs works as described in comment 0 on Fx 79.0a1 (2020-06-24) and Fx 78.0 across platforms (Windows 10, Ubuntu 18.04 and macOS 10.15), with the mention that the default behavior was verified in bug 1642431.
One question here, when attempting to open several times the downloaded file using a different key combination, for example I click the downloaded file 1 time and a new tab opens to the right, then using Ctrl + Shift +click the new tab is displayed to the left of the previously opened tab. Shouldn't it be opened to the right as well? Is this behavior expected?

Flags: needinfo?(sfoster)

(In reply to Anca Soncutean [:Anca], Desktop Release QA from comment #14)

One question here, when attempting to open several times the downloaded file using a different key combination, for example I click the downloaded file 1 time and a new tab opens to the right, then using Ctrl + Shift +click the new tab is displayed to the left of the previously opened tab. Shouldn't it be opened to the right as well? Is this behavior expected?

I'm not able to reproduce this as described. Yes, the default behavior (equivalent to ctrl+click) should open the PDF at the end (right in LTR) of the tab strip and switch to it. And Ctrl+shift+click should open another tab right of that one. This is true for clicks on items representing downloads in the browser UI - not necessarily for clicking links in content. If you can confirm STR to get the behavior you describe in comment 14 can you open a new bug for that?

Flags: needinfo?(sfoster) → needinfo?(anca.soncutean)
Flags: needinfo?(anca.soncutean)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: