mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 14:48:08 +02:00
Merge pull request #18651 from Rob--W/crx-mv3-prep-drop-manifest
[CRX] Remove obsolete manifest features
This commit is contained in:
commit
ce656238e3
12 changed files with 1 additions and 286 deletions
|
@ -23,7 +23,6 @@ limitations under the License.
|
|||
var schemes = [
|
||||
"http",
|
||||
"https",
|
||||
"ftp",
|
||||
"file",
|
||||
"chrome-extension",
|
||||
"blob",
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 679 B |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
|
@ -10,7 +10,6 @@
|
|||
"16": "icon16.png"
|
||||
},
|
||||
"permissions": [
|
||||
"fileBrowserHandler",
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"<all_urls>",
|
||||
|
@ -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:*",
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
})();
|
|
@ -1,44 +0,0 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<style>
|
||||
html {
|
||||
/* maximum width of popup as defined in Chromium's source code as kMaxWidth
|
||||
//src/chrome/browser/ui/views/extensions/extension_popup.cc
|
||||
//src/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc
|
||||
*/
|
||||
width: 800px;
|
||||
/* in case Chromium decides to lower the value of kMaxWidth */
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
body {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 5px;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body contentEditable="plaintext-only" spellcheck="false">
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -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();
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -18,7 +18,5 @@ limitations under the License.
|
|||
<script src="preserve-referer.js"></script>
|
||||
<script src="pdfHandler.js"></script>
|
||||
<script src="extension-router.js"></script>
|
||||
<script src="pdfHandler-vcros.js"></script>
|
||||
<script src="pageAction/background.js"></script>
|
||||
<script src="suppress-update.js"></script>
|
||||
<script src="telemetry.js"></script>
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
})();
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue