diff --git a/extensions/chromium/extension-router.js b/extensions/chromium/extension-router.js index ecb9004d822bc..a128a30d111e0 100644 --- a/extensions/chromium/extension-router.js +++ b/extensions/chromium/extension-router.js @@ -23,7 +23,6 @@ limitations under the License. var schemes = [ "http", "https", - "ftp", "file", "chrome-extension", "blob", diff --git a/extensions/chromium/icon19.png b/extensions/chromium/icon19.png deleted file mode 100644 index 1f67a12883e1f..0000000000000 Binary files a/extensions/chromium/icon19.png and /dev/null differ diff --git a/extensions/chromium/icon38.png b/extensions/chromium/icon38.png deleted file mode 100644 index 227452fb7d04c..0000000000000 Binary files a/extensions/chromium/icon38.png and /dev/null differ diff --git a/extensions/chromium/manifest.json b/extensions/chromium/manifest.json index e90ae5700e72e..77c39c7770226 100644 --- a/extensions/chromium/manifest.json +++ b/extensions/chromium/manifest.json @@ -10,7 +10,6 @@ "16": "icon16.png" }, "permissions": [ - "fileBrowserHandler", "webRequest", "webRequestBlocking", "", @@ -20,21 +19,13 @@ ], "content_scripts": [ { - "matches": ["http://*/*", "https://*/*", "ftp://*/*", "file://*/*"], + "matches": ["http://*/*", "https://*/*", "file://*/*"], "run_at": "document_start", "all_frames": true, "css": ["contentstyle.css"], "js": ["contentscript.js"] } ], - "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", - "file_browser_handlers": [ - { - "id": "open-as-pdf", - "default_title": "Open with PDF Viewer", - "file_filters": ["filesystem:*.pdf"] - } - ], "storage": { "managed_schema": "preferences_schema.json" }, @@ -46,20 +37,11 @@ "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": [ "content/web/viewer.html", "http:/*", "https:/*", - "ftp:/*", "file:/*", "chrome-extension:/*", "blob:*", diff --git a/extensions/chromium/pageAction/background.js b/extensions/chromium/pageAction/background.js deleted file mode 100644 index e19697039d0d7..0000000000000 --- a/extensions/chromium/pageAction/background.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright 2014 Mozilla Foundation - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -"use strict"; - -(function PageActionClosure() { - /** - * @param {number} tabId - ID of tab where the page action will be shown. - * @param {string} url - URL to be displayed in page action. - */ - function showPageAction(tabId, displayUrl) { - // rewriteUrlClosure in viewer.js ensures that the URL looks like - // chrome-extension://[extensionid]/http://example.com/file.pdf - var url = /^chrome-extension:\/\/[a-p]{32}\/([^#]+)/.exec(displayUrl); - if (url) { - url = url[1]; - chrome.pageAction.setPopup({ - tabId, - popup: "/pageAction/popup.html?file=" + encodeURIComponent(url), - }); - chrome.pageAction.show(tabId); - } else { - console.log("Unable to get PDF url from " + displayUrl); - } - } - - chrome.runtime.onMessage.addListener(function (message, sender) { - if (message === "showPageAction" && sender.tab) { - showPageAction(sender.tab.id, sender.tab.url); - } - }); -})(); diff --git a/extensions/chromium/pageAction/popup.html b/extensions/chromium/pageAction/popup.html deleted file mode 100644 index f18ff2752a4f7..0000000000000 --- a/extensions/chromium/pageAction/popup.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - diff --git a/extensions/chromium/pageAction/popup.js b/extensions/chromium/pageAction/popup.js deleted file mode 100644 index 317759452ceac..0000000000000 --- a/extensions/chromium/pageAction/popup.js +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2012 Mozilla Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -"use strict"; - -var url = location.search.match(/[&?]file=([^&]+)/i); -if (url) { - url = decodeURIComponent(url[1]); - document.body.textContent = url; - // Set cursor to end of the content-editable section. - window.getSelection().selectAllChildren(document.body); - window.getSelection().collapseToEnd(); -} diff --git a/extensions/chromium/pdfHandler-vcros.js b/extensions/chromium/pdfHandler-vcros.js deleted file mode 100644 index e584d3ac85eb6..0000000000000 --- a/extensions/chromium/pdfHandler-vcros.js +++ /dev/null @@ -1,102 +0,0 @@ -/* -Copyright 2014 Mozilla Foundation - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* eslint strict: ["error", "function"] */ -/* globals getViewerURL */ - -(function () { - "use strict"; - - if (!chrome.fileBrowserHandler) { - // Not on Chromium OS, bail out - return; - } - chrome.fileBrowserHandler.onExecute.addListener(onExecuteFileBrowserHandler); - - /** - * Invoked when "Open with PDF Viewer" is chosen in the File browser. - * - * @param {string} id File browser action ID as specified in - * manifest.json - * @param {Object} details Object of type FileHandlerExecuteEventDetails - */ - function onExecuteFileBrowserHandler(id, details) { - if (id !== "open-as-pdf") { - return; - } - var fileEntries = details.entries; - // "tab_id" is the currently documented format, but it is inconsistent with - // the other Chrome APIs that use "tabId" (http://crbug.com/179767) - var tabId = details.tab_id || details.tabId; - if (tabId > 0) { - chrome.tabs.get(tabId, function (tab) { - openViewer(tab && tab.windowId, fileEntries); - }); - } else { - // Re-use existing window, if available. - chrome.windows.getLastFocused(function (chromeWindow) { - var windowId = chromeWindow && chromeWindow.id; - if (windowId) { - chrome.windows.update(windowId, { focused: true }); - } - openViewer(windowId, fileEntries); - }); - } - } - - /** - * Open the PDF Viewer for the given list of PDF files. - * - * @param {number} windowId - * @param {Array} fileEntries List of Entry objects (HTML5 FileSystem API) - */ - function openViewer(windowId, fileEntries) { - if (!fileEntries.length) { - return; - } - var fileEntry = fileEntries.shift(); - var url = fileEntry.toURL(); - // Use drive: alias to get shorter (more human-readable) URLs. - url = url.replace( - /^filesystem:chrome-extension:\/\/[a-p]{32}\/external\//, - "drive:" - ); - url = getViewerURL(url); - - if (windowId) { - chrome.tabs.create( - { - windowId, - active: true, - url, - }, - function () { - openViewer(windowId, fileEntries); - } - ); - } else { - chrome.windows.create( - { - type: "normal", - focused: true, - url, - }, - function (chromeWindow) { - openViewer(chromeWindow.id, fileEntries); - } - ); - } - } -})(); diff --git a/extensions/chromium/pdfHandler.html b/extensions/chromium/pdfHandler.html index a87cec438786f..7a5a036e9c4d5 100644 --- a/extensions/chromium/pdfHandler.html +++ b/extensions/chromium/pdfHandler.html @@ -18,7 +18,5 @@ - - diff --git a/extensions/chromium/preserve-referer.js b/extensions/chromium/preserve-referer.js index 0803bd8c4b12d..5e53782b66be2 100644 --- a/extensions/chromium/preserve-referer.js +++ b/extensions/chromium/preserve-referer.js @@ -87,11 +87,6 @@ chrome.runtime.onConnect.addListener(function onReceivePort(port) { if (port.name !== "chromecom-referrer") { return; } - // Note: sender.frameId is only set in Chrome 41+. - if (!("frameId" in port.sender)) { - port.disconnect(); - return; - } var tabId = port.sender.tab.id; var frameId = port.sender.frameId; @@ -127,21 +122,8 @@ chrome.runtime.onConnect.addListener(function onReceivePort(port) { delete g_referrers[tabId][frameId]; } chrome.webRequest.onBeforeSendHeaders.removeListener(onBeforeSendHeaders); - chrome.webRequest.onHeadersReceived.removeListener(exposeOnHeadersReceived); }); - // Expose some response headers for fetch API calls from PDF.js; - // This is a work-around for https://crbug.com/784528 - chrome.webRequest.onHeadersReceived.addListener( - exposeOnHeadersReceived, - { - urls: ["https://*/*"], - types: ["xmlhttprequest"], - tabId, - }, - ["blocking", "responseHeaders"] - ); - function onBeforeSendHeaders(details) { if (details.frameId !== frameId) { return undefined; @@ -162,22 +144,4 @@ chrome.runtime.onConnect.addListener(function onReceivePort(port) { refererHeader.value = referer; return { requestHeaders: headers }; } - - function exposeOnHeadersReceived(details) { - if (details.frameId !== frameId) { - return undefined; - } - var headers = details.responseHeaders; - var aceh = getHeaderFromHeaders(headers, "access-control-expose-headers"); - // List of headers that PDF.js uses in src/display/network_utils.js - var acehValue = - "accept-ranges,content-encoding,content-length,content-disposition"; - if (aceh) { - aceh.value += "," + acehValue; - } else { - aceh = { name: "Access-Control-Expose-Headers", value: acehValue }; - headers.push(aceh); - } - return { responseHeaders: headers }; - } }); diff --git a/web/chromecom.js b/web/chromecom.js index b33e445377cf0..cb95a89c2ab11 100644 --- a/web/chromecom.js +++ b/web/chromecom.js @@ -36,9 +36,6 @@ if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) { // Example: chrome-extension://.../http://example.com/file.pdf const humanReadableUrl = "/" + defaultUrl + location.hash; history.replaceState(history.state, "", humanReadableUrl); - if (top === window) { - chrome.runtime.sendMessage("showPageAction"); - } AppOptions.set("defaultUrl", defaultUrl); })(); diff --git a/web/pdf_history.js b/web/pdf_history.js index 5d3baa38d8f0f..6c965ffbb9f57 100644 --- a/web/pdf_history.js +++ b/web/pdf_history.js @@ -394,15 +394,6 @@ class PDFHistory { } else { window.history.pushState(newState, "", newUrl); } - - if ( - typeof PDFJSDev !== "undefined" && - PDFJSDev.test("CHROME") && - top === window - ) { - // eslint-disable-next-line no-undef - chrome.runtime.sendMessage("showPageAction"); - } } #tryPushCurrentPosition(temporary = false) {