Closed
Bug 1245636
Opened 7 years ago
Closed 7 years ago
Implement chrome.downloads.open()
Categories
(WebExtensions :: Untriaged, defect)
WebExtensions
Untriaged
Tracking
(firefox48 fixed)
RESOLVED
FIXED
mozilla48
Tracking | Status | |
---|---|---|
firefox48 | --- | fixed |
People
(Reporter: aswan, Assigned: mstriemer)
References
(Blocks 1 open bug)
Details
(Whiteboard: [downloads][good first bug])
Attachments
(1 file, 1 obsolete file)
Part of supporting chrome.downloads in WebExtensions https://developer.chrome.com/extensions/downloads#method-open
Updated•7 years ago
|
Whiteboard: [downloads]
Reporter | ||
Updated•7 years ago
|
Whiteboard: [downloads] → [downloads][good first bug]
Assignee | ||
Updated•7 years ago
|
Assignee: nobody → mstriemer
Status: NEW → ASSIGNED
Assignee | ||
Comment 1•7 years ago
|
||
Attachment #8730130 -
Flags: review?(kmaglione+bmo)
Comment 2•7 years ago
|
||
Comment on attachment 8730130 [details] [diff] [review] Implement chrome.downloads.open Review of attachment 8730130 [details] [diff] [review]: ----------------------------------------------------------------- This looks good, but we need some tests, and some additional error checking. ::: toolkit/components/extensions/ext-downloads.js @@ +458,5 @@ > }, > > + open(downloadId) { > + if (!extension.hasPermission("downloads.open")) { > + throw new context.cloneScope.Error("Permission denied because 'downloads.open' permission is missing."); We need a test that this permission is enforced. @@ +461,5 @@ > + if (!extension.hasPermission("downloads.open")) { > + throw new context.cloneScope.Error("Permission denied because 'downloads.open' permission is missing."); > + } > + DownloadMap.lazyInit().then(() => { > + let download = DownloadMap.fromId(downloadId); We need to handle cases where the download ID is invalid, the download is incomplete, or the file doesn't exist. We should also change this API to return a promise, since the Chrome API requires us to set `lastError` if this fails. @@ +463,5 @@ > + } > + DownloadMap.lazyInit().then(() => { > + let download = DownloadMap.fromId(downloadId); > + let fileobj = new FileUtils.File(download.filename); > + fileobj.launch(); We should be calling the Download object's launch() method instead of creating a nsIFile object. We also need to fire an `onChanged` event for this, apparently. We probably need to do the same if it's opened from the ordinary download manager.
Attachment #8730130 -
Flags: review?(kmaglione+bmo)
Assignee | ||
Comment 3•7 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/39779/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/39779/
Attachment #8730253 -
Flags: review?(kmaglione+bmo)
Reporter | ||
Updated•7 years ago
|
Attachment #8730130 -
Attachment is obsolete: true
Assignee | ||
Comment 4•7 years ago
|
||
As discussed in person, Chrome does not actually fire the `onChanged` event so this does not fire it either.
Updated•7 years ago
|
Attachment #8730253 -
Flags: review?(kmaglione+bmo) → review+
Comment 5•7 years ago
|
||
Comment on attachment 8730253 [details] MozReview Request: bug 1245636 - Implement chrome.downloads.open r?kmag https://reviewboard.mozilla.org/r/39779/#review36601 ::: toolkit/components/extensions/ext-downloads.js:469 (Diff revision 1) > + } > + return DownloadMap.lazyInit().then(() => { > + try { > + let download = DownloadMap.fromId(downloadId).download; > + if (download.succeeded) { > + download.launch(); This returns a promise, so you need to return it. ::: toolkit/components/extensions/ext-downloads.js:473 (Diff revision 1) > + if (download.succeeded) { > + download.launch(); > + } else { > + return Promise.reject({message: "Download has not completed."}); > + } > + } catch (error) { Please make this a `.catch()` clause rather than a try-catch statement.
Assignee | ||
Comment 6•7 years ago
|
||
Comment on attachment 8730253 [details] MozReview Request: bug 1245636 - Implement chrome.downloads.open r?kmag Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39779/diff/1-2/
Assignee | ||
Updated•7 years ago
|
Keywords: checkin-needed
Assignee | ||
Comment 8•7 years ago
|
||
Comment on attachment 8730253 [details] MozReview Request: bug 1245636 - Implement chrome.downloads.open r?kmag Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39779/diff/2-3/
Comment 10•7 years ago
|
||
Sorry to do this to you, but this needs rebasing against fx-team again :(
Keywords: checkin-needed
Comment 12•7 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/058cc8ccfff3
Keywords: checkin-needed
Assignee | ||
Comment 13•7 years ago
|
||
Comment on attachment 8730253 [details] MozReview Request: bug 1245636 - Implement chrome.downloads.open r?kmag Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39779/diff/3-4/
Comment 14•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/058cc8ccfff3
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox48:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
Updated•5 years ago
|
Product: Toolkit → WebExtensions
You need to log in
before you can comment on or make changes to this bug.
Description
•