Bug 924571 - Address review comments for Shumway integration patch. r=gavin

--HG--
rename : browser/extensions/shumway/components/FlashStreamConverter.js => browser/extensions/shumway/content/ShumwayStreamConverter.jsm
This commit is contained in:
Yury Delendik 2013-10-17 16:11:52 -05:00
parent dcf9c27036
commit 8b4efe017c
6 changed files with 32 additions and 52 deletions

View File

@ -1,2 +1 @@
resource shumway content/
resource shumway.components components/

View File

@ -18,14 +18,13 @@
'use strict';
var EXPORTED_SYMBOLS = ['FlashStreamConverter1', 'FlashStreamConverter2'];
var EXPORTED_SYMBOLS = ['ShumwayStreamConverter', 'ShumwayStreamOverlayConverter'];
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
// True only if this is the version of pdf.js that is included with firefox.
const SHUMWAY_CONTENT_TYPE = 'application/x-shockwave-flash';
const EXPECTED_PLAYPREVIEW_URI_PREFIX = 'data:application/x-moz-playpreview;,' +
SHUMWAY_CONTENT_TYPE;
@ -66,7 +65,7 @@ function getStringPref(pref, def) {
}
function log(aMsg) {
let msg = 'FlashStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
let msg = 'ShumwayStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
Services.console.logStringMessage(msg);
dump(msg + '\n');
}
@ -636,10 +635,10 @@ function initExternalCom(wrappedWindow, wrappedObject, targetDocument) {
};
}
function FlashStreamConverterBase() {
function ShumwayStreamConverterBase() {
}
FlashStreamConverterBase.prototype = {
ShumwayStreamConverterBase.prototype = {
QueryInterface: XPCOMUtils.generateQI([
Ci.nsISupports,
Ci.nsIStreamConverter,
@ -852,22 +851,22 @@ function copyProperties(obj, template) {
}
}
function FlashStreamConverter1() {}
FlashStreamConverter1.prototype = new FlashStreamConverterBase();
copyProperties(FlashStreamConverter1.prototype, {
function ShumwayStreamConverter() {}
ShumwayStreamConverter.prototype = new ShumwayStreamConverterBase();
copyProperties(ShumwayStreamConverter.prototype, {
classID: Components.ID('{4c6030f7-e20a-264f-5b0e-ada3a9e97384}'),
classDescription: 'Shumway Content Converter Component',
contractID: '@mozilla.org/streamconv;1?from=application/x-shockwave-flash&to=*/*'
});
function FlashStreamConverter2() {}
FlashStreamConverter2.prototype = new FlashStreamConverterBase();
copyProperties(FlashStreamConverter2.prototype, {
function ShumwayStreamOverlayConverter() {}
ShumwayStreamOverlayConverter.prototype = new ShumwayStreamConverterBase();
copyProperties(ShumwayStreamOverlayConverter.prototype, {
classID: Components.ID('{4c6030f7-e20a-264f-5f9b-ada3a9e97384}'),
classDescription: 'Shumway PlayPreview Component',
contractID: '@mozilla.org/streamconv;1?from=application/x-moz-playpreview&to=*/*'
});
FlashStreamConverter2.prototype.isValidRequest =
ShumwayStreamOverlayConverter.prototype.isValidRequest =
(function(aCtxt) {
try {
var request = aCtxt;
@ -878,9 +877,6 @@ FlashStreamConverter2.prototype.isValidRequest =
return false;
}
});
FlashStreamConverter2.prototype.getUrlHint = function (requestUrl) {
ShumwayStreamOverlayConverter.prototype.getUrlHint = function (requestUrl) {
return '';
};
var NSGetFactory1 = XPCOMUtils.generateNSGetFactory([FlashStreamConverter1]);
var NSGetFactory2 = XPCOMUtils.generateNSGetFactory([FlashStreamConverter2]);

View File

@ -29,7 +29,7 @@ let Cu = Components.utils;
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://shumway.components/FlashStreamConverter.js');
Cu.import('resource://shumway/ShumwayStreamConverter.jsm');
let Svc = {};
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime',
@ -51,44 +51,30 @@ function log(str) {
dump(str + '\n');
}
// Register/unregister a constructor as a component.
// Register/unregister a constructor as a factory.
function Factory() {}
Factory.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]),
_targetConstructor: null,
register: function register(targetConstructor) {
this._targetConstructor = targetConstructor;
var proto = targetConstructor.prototype;
this._classID = proto.classID;
var factory = XPCOMUtils._getFactory(targetConstructor);
this._factory = factory;
var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(proto.classID, proto.classDescription,
proto.contractID, this);
proto.contractID, factory);
},
unregister: function unregister() {
var proto = this._targetConstructor.prototype;
var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(proto.classID, this);
this._targetConstructor = null;
},
// nsIFactory
createInstance: function createInstance(aOuter, iid) {
if (aOuter !== null)
throw Cr.NS_ERROR_NO_AGGREGATION;
return (new (this._targetConstructor)).QueryInterface(iid);
},
// nsIFactory
lockFactory: function lockFactory(lock) {
// No longer used as of gecko 1.7.
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
registrar.unregisterFactory(this._classID, this._factory);
this._factory = null;
}
};
let factory1 = new Factory();
let factory2 = new Factory();
let converterFactory = new Factory();
let overlayConverterFactory = new Factory();
let ShumwayUtils = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
@ -113,8 +99,7 @@ let ShumwayUtils = {
},
/**
* shumway is only enabled if it is both selected as the pdf viewer and if the
* global switch enabling it is true.
* shumway is only enabled if the global switch enabling is true.
* @return {boolean} Wether or not it's enabled.
*/
get enabled() {
@ -126,8 +111,8 @@ let ShumwayUtils = {
return;
// Load the component and register it.
factory1.register(FlashStreamConverter1);
factory2.register(FlashStreamConverter2);
converterFactory.register(ShumwayStreamConverter);
overlayConverterFactory.register(ShumwayStreamOverlayConverter);
var ignoreCTP = getBoolPref(PREF_IGNORE_CTP, true);
@ -143,8 +128,8 @@ let ShumwayUtils = {
return;
// Remove the contract/component.
factory1.unregister();
factory2.unregister();
converterFactory.unregister();
overlayConverterFactory.unregister();
Svc.pluginHost.unregisterPlayPreviewMimeType(SWF_CONTENT_TYPE);

View File

@ -1 +1 @@
0.7.351
0.7.352

View File

@ -16,7 +16,7 @@
* limitations under the License.
*/
// Extension communication object... as it used in pdf.js
// Extension communication object
var FirefoxCom = (function FirefoxComClosure() {
return {
/**

View File

@ -17,7 +17,7 @@
*/
// Extenstion communication object... as it used in pdf.js
// Extenstion communication object
var FirefoxCom = (function FirefoxComClosure() {
return {
/**