Removes PdfRedirector.js and PlayPreview support.
This commit is contained in:
parent
9e9df5600f
commit
4f3f983a21
24
extensions/firefox/bootstrap.js
vendored
24
extensions/firefox/bootstrap.js
vendored
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
/* jshint esnext:true */
|
/* jshint esnext:true */
|
||||||
/* globals Components, Services, dump, XPCOMUtils, PdfStreamConverter,
|
/* globals Components, Services, dump, XPCOMUtils, PdfStreamConverter,
|
||||||
PdfRedirector, APP_SHUTDOWN, PdfjsChromeUtils, PdfjsContentUtils,
|
APP_SHUTDOWN, PdfjsChromeUtils, PdfjsContentUtils,
|
||||||
DEFAULT_PREFERENCES */
|
DEFAULT_PREFERENCES */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -33,9 +33,6 @@ const Cr = Components.results;
|
|||||||
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||||
Cu.import('resource://gre/modules/Services.jsm');
|
Cu.import('resource://gre/modules/Services.jsm');
|
||||||
|
|
||||||
var Ph = Cc['@mozilla.org/plugin/host;1'].getService(Ci.nsIPluginHost);
|
|
||||||
var registerOverlayPreview = 'getPlayPreviewInfo' in Ph;
|
|
||||||
|
|
||||||
function getBoolPref(pref, def) {
|
function getBoolPref(pref, def) {
|
||||||
try {
|
try {
|
||||||
return Services.prefs.getBoolPref(pref);
|
return Services.prefs.getBoolPref(pref);
|
||||||
@ -120,7 +117,6 @@ Factory.prototype = {
|
|||||||
|
|
||||||
var pdfStreamConverterFactory = new Factory();
|
var pdfStreamConverterFactory = new Factory();
|
||||||
var pdfBaseUrl = null;
|
var pdfBaseUrl = null;
|
||||||
var pdfRedirectorFactory = new Factory();
|
|
||||||
var e10sEnabled = false;
|
var e10sEnabled = false;
|
||||||
|
|
||||||
// As of Firefox 13 bootstrapped add-ons don't support automatic registering and
|
// As of Firefox 13 bootstrapped add-ons don't support automatic registering and
|
||||||
@ -147,15 +143,6 @@ function startup(aData, aReason) {
|
|||||||
Cu.import(pdfStreamConverterUrl);
|
Cu.import(pdfStreamConverterUrl);
|
||||||
pdfStreamConverterFactory.register(PdfStreamConverter);
|
pdfStreamConverterFactory.register(PdfStreamConverter);
|
||||||
|
|
||||||
if (registerOverlayPreview) {
|
|
||||||
var pdfRedirectorUrl = pdfBaseUrl + 'content/PdfRedirector.jsm';
|
|
||||||
Cu.import(pdfRedirectorUrl);
|
|
||||||
pdfRedirectorFactory.register(PdfRedirector);
|
|
||||||
|
|
||||||
Ph.registerPlayPreviewMimeType('application/pdf', true,
|
|
||||||
'data:application/x-moz-playpreview-pdfjs;,');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let globalMM = Cc['@mozilla.org/globalmessagemanager;1']
|
let globalMM = Cc['@mozilla.org/globalmessagemanager;1']
|
||||||
.getService(Ci.nsIFrameScriptLoader);
|
.getService(Ci.nsIFrameScriptLoader);
|
||||||
@ -190,15 +177,6 @@ function shutdown(aData, aReason) {
|
|||||||
var pdfStreamConverterUrl = pdfBaseUrl + 'content/PdfStreamConverter.jsm';
|
var pdfStreamConverterUrl = pdfBaseUrl + 'content/PdfStreamConverter.jsm';
|
||||||
Cu.unload(pdfStreamConverterUrl);
|
Cu.unload(pdfStreamConverterUrl);
|
||||||
|
|
||||||
if (registerOverlayPreview) {
|
|
||||||
pdfRedirectorFactory.unregister();
|
|
||||||
var pdfRedirectorUrl = pdfBaseUrl + 'content/PdfRedirector.jsm';
|
|
||||||
Cu.unload(pdfRedirectorUrl);
|
|
||||||
pdfRedirectorUrl = null;
|
|
||||||
|
|
||||||
Ph.unregisterPlayPreviewMimeType('application/pdf');
|
|
||||||
}
|
|
||||||
|
|
||||||
PdfjsContentUtils.uninit();
|
PdfjsContentUtils.uninit();
|
||||||
Cu.unload(pdfBaseUrl + 'content/PdfjsContentUtils.jsm');
|
Cu.unload(pdfBaseUrl + 'content/PdfjsContentUtils.jsm');
|
||||||
PdfjsChromeUtils.uninit();
|
PdfjsChromeUtils.uninit();
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* jshint esnext:true */
|
/* jshint esnext:true */
|
||||||
/* globals Components, Services, XPCOMUtils, PdfjsChromeUtils, PdfRedirector,
|
/* globals Components, Services, XPCOMUtils, PdfjsChromeUtils,
|
||||||
PdfjsContentUtils, DEFAULT_PREFERENCES, PdfStreamConverter */
|
PdfjsContentUtils, DEFAULT_PREFERENCES, PdfStreamConverter */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -1,137 +0,0 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
|
||||||
/* 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.
|
|
||||||
*/
|
|
||||||
/* jshint esnext:true */
|
|
||||||
/* globals Components, Services, XPCOMUtils, NetUtil, dump */
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ['PdfRedirector'];
|
|
||||||
|
|
||||||
const Cc = Components.classes;
|
|
||||||
const Ci = Components.interfaces;
|
|
||||||
const Cr = Components.results;
|
|
||||||
const Cu = Components.utils;
|
|
||||||
|
|
||||||
const PDF_CONTENT_TYPE = 'application/pdf';
|
|
||||||
const FIREFOX_ID = '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}';
|
|
||||||
|
|
||||||
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
|
||||||
Cu.import('resource://gre/modules/Services.jsm');
|
|
||||||
Cu.import('resource://gre/modules/NetUtil.jsm');
|
|
||||||
|
|
||||||
|
|
||||||
function getDOMWindow(aChannel) {
|
|
||||||
var requestor = aChannel.notificationCallbacks ?
|
|
||||||
aChannel.notificationCallbacks :
|
|
||||||
aChannel.loadGroup.notificationCallbacks;
|
|
||||||
var win = requestor.getInterface(Components.interfaces.nsIDOMWindow);
|
|
||||||
return win;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getObjectUrl(window) {
|
|
||||||
// PlayPreview overlay "belongs" to the embed/object tag and consists of DIV
|
|
||||||
// and IFRAME. Starting from IFRAME and looking for first object tag.
|
|
||||||
var element = window.frameElement, containerElement;
|
|
||||||
if (!element) {
|
|
||||||
return null; // iframe tag
|
|
||||||
}
|
|
||||||
var tagName = element.nodeName;
|
|
||||||
while (tagName !== 'EMBED' && tagName !== 'OBJECT') {
|
|
||||||
containerElement = element;
|
|
||||||
element = element.parentNode;
|
|
||||||
if (!element) {
|
|
||||||
return null; // object tag was not found
|
|
||||||
}
|
|
||||||
tagName = element.nodeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checking if overlay is a proper PlayPreview overlay.
|
|
||||||
if (element.displayedType !== element.TYPE_NULL ||
|
|
||||||
element.pluginFallbackType !== element.PLUGIN_PLAY_PREVIEW) {
|
|
||||||
return null; // invalid plugin element overlay state
|
|
||||||
}
|
|
||||||
for (var i = 0; i < element.children.length; i++) {
|
|
||||||
if (element.children[i] === containerElement) {
|
|
||||||
return null; // invalid plugin element overlay
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return element.srcURI.spec;
|
|
||||||
}
|
|
||||||
|
|
||||||
function PdfRedirector() {
|
|
||||||
}
|
|
||||||
|
|
||||||
PdfRedirector.prototype = {
|
|
||||||
|
|
||||||
// properties required for XPCOM registration:
|
|
||||||
classID: Components.ID('{8cbfd8d0-2042-4976-b3ef-d9dee1efb975}'),
|
|
||||||
classDescription: 'pdf.js Redirector',
|
|
||||||
contractID:
|
|
||||||
'@mozilla.org/streamconv;1?from=application/x-moz-playpreview-pdfjs&to=*/*',
|
|
||||||
|
|
||||||
QueryInterface: XPCOMUtils.generateQI([
|
|
||||||
Ci.nsIStreamConverter,
|
|
||||||
Ci.nsIStreamListener,
|
|
||||||
Ci.nsIRequestObserver
|
|
||||||
]),
|
|
||||||
|
|
||||||
// nsIStreamConverter::convert
|
|
||||||
convert: function(aFromStream, aFromType, aToType, aCtxt) {
|
|
||||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
},
|
|
||||||
|
|
||||||
// nsIStreamConverter::asyncConvertData
|
|
||||||
asyncConvertData: function(aFromType, aToType, aListener, aCtxt) {
|
|
||||||
// Store the listener passed to us
|
|
||||||
this.listener = aListener;
|
|
||||||
},
|
|
||||||
|
|
||||||
// nsIStreamListener::onDataAvailable
|
|
||||||
onDataAvailable: function(aRequest, aContext, aInputStream, aOffset, aCount) {
|
|
||||||
// Do nothing since all the data loading is handled by the viewer.
|
|
||||||
},
|
|
||||||
|
|
||||||
// nsIRequestObserver::onStartRequest
|
|
||||||
onStartRequest: function(aRequest, aContext) {
|
|
||||||
// Setup the request so we can use it below.
|
|
||||||
aRequest.QueryInterface(Ci.nsIChannel);
|
|
||||||
// Cancel the request so the viewer can handle it.
|
|
||||||
aRequest.cancel(Cr.NS_BINDING_ABORTED);
|
|
||||||
|
|
||||||
var domWindow = getDOMWindow(aRequest);
|
|
||||||
var pdfUrl = getObjectUrl(domWindow);
|
|
||||||
if (!pdfUrl) {
|
|
||||||
Services.console.logStringMessage(
|
|
||||||
'PdfRedirector.js: PDF location is not specified for OBJECT/EMBED tag');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new channel that is viewer loaded as a resource.
|
|
||||||
var ioService = Services.io;
|
|
||||||
var channel = ioService.newChannel(pdfUrl, null, null);
|
|
||||||
|
|
||||||
channel.loadGroup = aRequest.loadGroup;
|
|
||||||
|
|
||||||
channel.asyncOpen(this.listener, aContext);
|
|
||||||
},
|
|
||||||
|
|
||||||
// nsIRequestObserver::onStopRequest
|
|
||||||
onStopRequest: function(aRequest, aContext, aStatusCode) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
};
|
|
3
make.js
3
make.js
@ -107,8 +107,7 @@ var COMMON_WEB_FILES =
|
|||||||
COMMON_FIREFOX_FILES_PREPROCESS =
|
COMMON_FIREFOX_FILES_PREPROCESS =
|
||||||
[FIREFOX_CONTENT_DIR + 'PdfStreamConverter.jsm',
|
[FIREFOX_CONTENT_DIR + 'PdfStreamConverter.jsm',
|
||||||
FIREFOX_CONTENT_DIR + 'PdfjsContentUtils.jsm',
|
FIREFOX_CONTENT_DIR + 'PdfjsContentUtils.jsm',
|
||||||
FIREFOX_CONTENT_DIR + 'PdfjsChromeUtils.jsm',
|
FIREFOX_CONTENT_DIR + 'PdfjsChromeUtils.jsm'];
|
||||||
FIREFOX_CONTENT_DIR + 'PdfRedirector.jsm'];
|
|
||||||
//
|
//
|
||||||
// make generic
|
// make generic
|
||||||
// Builds the generic production viewer that should be compatible with most
|
// Builds the generic production viewer that should be compatible with most
|
||||||
|
Loading…
Reference in New Issue
Block a user