Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add session.downloadURL() #19889

Merged
merged 1 commit into from Aug 29, 2019
Merged

feat: add session.downloadURL() #19889

merged 1 commit into from Aug 29, 2019

Conversation

miniak
Copy link
Contributor

@miniak miniak commented Aug 22, 2019

Description of Change

Add session.downloadURL() allowing to trigger downloads without a BrowserWindow

Checklist

Release Notes

Notes: Added session.downloadURL() allowing to trigger downloads without a BrowserWindow.

@miniak miniak self-assigned this Aug 22, 2019
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Aug 22, 2019
docs/api/session.md Outdated Show resolved Hide resolved
@deepak1556
Copy link
Member

@miniak can you redirect the implementation of WebContents::DownloadURL to be based on this session api ?

@miniak
Copy link
Contributor Author

miniak commented Aug 22, 2019

@deepak1556 WebContents::DownloadURL() associates the download with the main frame of the webContents, which enforces some security checks, etc. I think the implementation has to be kept separate. Also it's not that much extra code, it's just few lines that trigger the download.

@miniak
Copy link
Contributor Author

miniak commented Aug 22, 2019

@deepak1556
Copy link
Member

deepak1556 commented Aug 22, 2019

associates the download with the main frame of the webContents, which enforces some security checks, etc

Yup but those are configurable via the download parameters which could be passed into, something like

void DownloadURL(const GURL& url,
                          std::unique_ptr<download::DownloadUrlParameters> params) {}

Having these api separate sounds good too, but I would like to maintain single point of implementation that uses content api if possible , so that we don't update multiple places if chromium decides to break api signature. These are just few lines as you mentioned, so not a concern here.

@miniak
Copy link
Contributor Author

miniak commented Aug 22, 2019

@deepak1556 I've updated the test to use session.defaultSession instead of w.webContents.session to make it clear that the API does not need a window

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Aug 23, 2019
@miniak
Copy link
Contributor Author

miniak commented Aug 23, 2019

@nornagon can you please review?

@nornagon
Copy link
Member

Should this replace webContents.downloadURL()? i.e. should we deprecate & remove that function with this as the replacement?

@MarshallOfSound
Copy link
Member

@nornagon See #19889 (comment)

@miniak miniak force-pushed the miniak/session-download branch 3 times, most recently from 06d6f62 to 2cb3ebc Compare August 28, 2019 07:23
@codebytere codebytere merged commit eed72c3 into master Aug 29, 2019
@release-clerk
Copy link

release-clerk bot commented Aug 29, 2019

Release Notes Persisted

Added session.downloadURL() allowing to trigger downloads without a BrowserWindow.

@codebytere codebytere deleted the miniak/session-download branch August 29, 2019 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants