Rob--W / pdf.js

PDF Reader in JavaScript
Apache License 2.0
5 stars 3 forks source link

Switch to chrome.streamsPrivate API #1

Closed Rob--W closed 8 years ago

Rob--W commented 11 years ago

The streams API allows the extension to directly capture the binary data of all PDF files, which results in support of POST and FTP requests.

The progress is recorded at https://github.com/Rob--W/pdf.js/tree/crx-using-streams-api, and each commit message contains an explanation of the changes made by that commit.
List of new commits: https://github.com/Rob--W/pdf.js/compare/crx-using-streams-api.

Testing

git clone https://github.com/Rob--W/pdf.js.git
git checkout crx-using-streams-api

# Add the key for whitelisted extension ID gbkeegbaiigmenfmjfclcdgdpimamgkj
sed -i 's/"mime_/"key":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC4zyYTii0VTKI7W2U6fDeAvs3YCVZeAt7C62IC64IDCMHvWy7SKMpOPjfg5v1PgYkFm+fGsCsVLN8NaF7fzYMVtjLc5bqhqPAi56Qidrqh1HxPAAYhwFQd5BVGhZmh1fySHXFPE8VI2tIHwRrASOtx67jbSEk4nBAcJz6n+eGq8QIDAQAB",\n"mime_/' build/chromium/manifest.json 

# If you want to test in Opera, use extension ID encfpfilknmenlmjemepncnlbbjlabkc
sed -i 's/"mime_/"key":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6EVXS6QZ/BAi5gQqOclGyEzpC/wLhNVP+D9+FtLPHxbVoLve9Kp96tAdumEsjnblGf8hZxumyIK859YBhf2Iwfqr5baV/s3gjIQ5aAxAE7EilxVdUaj42NH0rwYj/bPhEJeI2DSWoCqpgK21ZKmUBRLl515d38MFTsr6Tm41VtQIDAQAB",\n"mime_/' build/chromium/manifest.json 

node make generic chromium

chromium --user-data-dir=/tmp/whatever --load-extension=build/extensions/chromium --no-first-run

(adjust the last command to your needs, e.g. chrome.exe and/or --user-data-dir=%TMP%\whatever)

Progress

Enhancements (nice to have, not critical)

Rob--W commented 10 years ago

Rebased to master, successfully tested in Chrome/Chromium 28, 29, 30 and 31.

Rob--W commented 10 years ago

Created new ticket to request streamsPrivate permission at https://code.google.com/p/chromium/issues/detail?id=326949.

andreasbovens commented 10 years ago

chrome.streamsPrivate API is now supported in Opera Next, and the PDF.js (PDF Viewer) extension is whitelisted.

Rob--W commented 10 years ago

@andreasbovens Nice! Are the extension IDs of the PDF Viewer from the Chrome Web Store AND the one from addons.opera.com whitelisted?

oemmndcbldboiebfnladdacbdfmadadm (in the Chrome Web Store)
encfpfilknmenlmjemepncnlbbjlabkc (in the Opera Add-on Gallery)

Also, what is the Opera version that supports streamsPrivate?

andreasbovens commented 10 years ago

No, only the one in the Opera addons gallery is whitelisted, as that's the one we can review.

The Opera version that supports streamsPrivate is Opera 19 (for now, that's http://www.opera.com/computer/next).

5953lc commented 10 years ago

I tested Version PDF.js version 0.8.877 with Opera 20.0.1380.1 YES!!!!!

Now let's make it faster! ;)

Rob--W commented 10 years ago

Created separate issue on Mozilla's bug tracker for whitelist request at Chromium (because code is now upstream, it's relevant to Mozilla's repository as well).

https://github.com/mozilla/pdf.js/issues/4172

Rob--W commented 10 years ago

The streamsPrivate API is not needed any more for getting FTP access, because extensions can now request FTP data using plain XMLHttpRequest.

This feature was added with https://codereview.chromium.org/166793003/, and will be available from Chrome 35.0.1888.0.

Once if I figure out a way to get the data from a POST request, the streamsPrivate API will not be needed any more (API proposal: https://docs.google.com/document/d/1iE6M-YSmPtMOsec7pR-ILWveQie8JQQXTm15JKEcUT8/edit)