mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Improved FTP support for Chromium extension
This commit is contained in:
parent
7d5bf83ce8
commit
d04f81b964
5 changed files with 88 additions and 6 deletions
|
@ -15,7 +15,7 @@ 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.
|
||||
*/
|
||||
/* globals chrome */
|
||||
/* globals chrome, Features */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -172,6 +172,27 @@ chrome.webRequest.onHeadersReceived.addListener(
|
|||
},
|
||||
['blocking','responseHeaders']);
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function onBeforeRequestForFTP(details) {
|
||||
if (!Features.extensionSupportsFTP) {
|
||||
chrome.webRequest.onBeforeRequest.removeListener(onBeforeRequestForFTP);
|
||||
return;
|
||||
}
|
||||
if (isPdfDownloadable(details)) {
|
||||
return;
|
||||
}
|
||||
var viewerUrl = getViewerURL(details.url);
|
||||
return { redirectUrl: viewerUrl };
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
'ftp://*/*.pdf',
|
||||
'ftp://*/*.PDF'
|
||||
],
|
||||
types: ['main_frame', 'sub_frame']
|
||||
},
|
||||
['blocking']);
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function(details) {
|
||||
if (isPdfDownloadable(details)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue