This method captures all application/pdf streams, loads the viewer and passes the stream to the PDF.js viewer. This commit shows a proof of concept using the chrome.streamsPrivate API. Advantages of new method: - Access to the response body of the original request, thus fewer network requests. - PDFs from non-GET requests (e.g. POST) are now supported. - FTP files are also supported. Possible improvements: - Use declared content scripts instead of dynamic chrome.tabs.executeScript. This allows the extension to render the viewer in frames when the extension is disallowed to run executeScript for the top URL. - Use chrome.declarativeWebRequest instead of webRequest, and replace background page with event page (don't forget to profile the difference & will the background/event page still work as intended?).
53 lines
1.5 KiB
JSON
53 lines
1.5 KiB
JSON
{
|
|
"manifest_version": 2,
|
|
"name": "PDF Viewer",
|
|
"version": "PDFJSSCRIPT_VERSION",
|
|
"description": "Uses HTML5 to display PDF files directly in the browser.",
|
|
"icons": {
|
|
"128": "icon128.png",
|
|
"48": "icon48.png",
|
|
"16": "icon16.png"
|
|
},
|
|
"permissions": [
|
|
"webRequest", "webRequestBlocking",
|
|
"<all_urls>",
|
|
"tabs",
|
|
"webNavigation",
|
|
"streamsPrivate"
|
|
],
|
|
/* FOR demo & debugging purposes only! This key is required to get access to the streams API.
|
|
* This key forces the extension ID to be gbkeegbaiigmenfmjfclcdgdpimamgkj (= Chrome Office Viewer)
|
|
* This comment has been added to prevent it from being uploaded to the Chrome Web Store.
|
|
* Remove it when the PDF.js extensionID is whitelisted for the streamsPrivate API.
|
|
*/
|
|
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC4zyYTii0VTKI7W2U6fDeAvs3YCVZeAt7C62IC64IDCMHvWy7SKMpOPjfg5v1PgYkFm+fGsCsVLN8NaF7fzYMVtjLc5bqhqPAi56Qidrqh1HxPAAYhwFQd5BVGhZmh1fySHXFPE8VI2tIHwRrASOtx67jbSEk4nBAcJz6n+eGq8QIDAQAB",
|
|
"content_scripts": [{
|
|
"matches": ["file://*/*"],
|
|
"js": ["nothing.js"]
|
|
}],
|
|
"mime_types": [
|
|
"application/pdf"
|
|
],
|
|
"background": {
|
|
"page": "pdfHandler.html"
|
|
},
|
|
"page_action": {
|
|
"default_icon": {
|
|
"19": "icon19.png",
|
|
"38": "icon38.png"
|
|
},
|
|
"default_title": "Show PDF URL",
|
|
"default_popup": "pageActionPopup.html"
|
|
},
|
|
"incognito": "split",
|
|
"web_accessible_resources": [
|
|
"getFrameId",
|
|
"content/web/viewer.html",
|
|
"http:/*",
|
|
"https:/*",
|
|
"ftp:/*",
|
|
"file:/*",
|
|
"chrome-extension:/*"
|
|
]
|
|
}
|