Bug 1192450 - Remove PlayPreview registration from Shumway. r=jet

--HG--
extra : amend_source : cd9b8cd949cc2354d6166987cfb7c1fb00beb372
This commit is contained in:
Yury Delendik 2015-08-18 11:24:16 -05:00
parent b703709b06
commit 2ea982f244
7 changed files with 51 additions and 32 deletions

View File

@ -1689,13 +1689,7 @@ pref("pdfjs.previousHandler.alwaysAskBeforeHandling", false);
// Shumway is only bundled in Nightly.
#ifdef NIGHTLY_BUILD
// By default, Shumway (SWF player) is only enabled for whitelisted SWFs on Windows + OS X.
#ifdef UNIX_BUT_NOT_MAC
pref("shumway.disabled", true);
#else
pref("shumway.disabled", false);
pref("shumway.swf.whitelist", "http://www.areweflashyet.com/*.swf");
#endif
#endif
// The maximum amount of decoded image data we'll willingly keep around (we

View File

@ -69,11 +69,20 @@ Factory.prototype = {
var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(proto.classID, proto.classDescription,
proto.contractID, factory);
if (proto.classID2) {
this._classID2 = proto.classID2;
registrar.registerFactory(proto.classID2, proto.classDescription,
proto.contractID2, factory);
}
},
unregister: function unregister() {
var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(this._classID, this._factory);
if (this._classID2) {
registrar.unregisterFactory(this._classID2, this._factory);
}
}
};
@ -128,25 +137,6 @@ var ShumwayBootstrapUtils = {
let converterFactory = new Factory();
converterFactory.register(ShumwayStreamConverter);
this.converterFactory = converterFactory;
let overlayConverterFactory = new Factory();
overlayConverterFactory.register(ShumwayStreamOverlayConverter);
this.overlayConverterFactory = overlayConverterFactory;
let registerOverlayPreview = 'registerPlayPreviewMimeType' in Ph;
if (registerOverlayPreview) {
var ignoreCTP = getBoolPref(PREF_IGNORE_CTP, true);
var whitelist = getStringPref(PREF_WHITELIST);
// Some platforms cannot support video playback, and our whitelist targets
// only video players atm. We need to disable Shumway for those platforms.
if (whitelist && !Services.prefs.prefHasUserValue(PREF_WHITELIST) && !allowedPlatformForMedia()) {
log('Default SWF whitelist is used on an unsupported platform -- ' +
'using demo whitelist.');
whitelist = 'http://www.areweflashyet.com/*.swf';
}
Ph.registerPlayPreviewMimeType(SWF_CONTENT_TYPE, ignoreCTP,
undefined, whitelist);
}
this.registerOverlayPreview = registerOverlayPreview;
}
},
@ -163,12 +153,6 @@ var ShumwayBootstrapUtils = {
} else {
this.converterFactory.unregister();
this.converterFactory = null;
this.overlayConverterFactory.unregister();
this.overlayConverterFactory = null;
if (this.registerOverlayPreview) {
Ph.unregisterPlayPreviewMimeType(SWF_CONTENT_TYPE);
}
}
}
};

View File

@ -403,7 +403,10 @@ 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=*/*'
contractID: '@mozilla.org/streamconv;1?from=application/x-shockwave-flash&to=*/*',
classID2: Components.ID('{4c6030f8-e20a-264f-5b0e-ada3a9e97384}'),
contractID2: '@mozilla.org/streamconv;1?from=application/x-shockwave-flash&to=text/html'
});
function ShumwayStreamOverlayConverter() {}

View File

@ -51,6 +51,13 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
return NS_OK;
}
// We want to claim that the type for SWF movies is unsupported,
// so that the internal SWF player's stream converter will get used.
if (aType.LowerCaseEqualsLiteral("application/x-shockwave-flash") &&
nsContentUtils::IsSWFPlayerEnabled()) {
return NS_OK;
}
const nsCString& flatType = PromiseFlatCString(aType);
nsresult rv = IsTypeSupportedInternal(flatType, aIsTypeSupported);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -6578,6 +6578,20 @@ nsContentUtils::IsPDFJSEnabled()
return NS_SUCCEEDED(rv) && canConvert;
}
bool
nsContentUtils::IsSWFPlayerEnabled()
{
nsCOMPtr<nsIStreamConverterService> convServ =
do_GetService("@mozilla.org/streamConverters;1");
nsresult rv = NS_ERROR_FAILURE;
bool canConvert = false;
if (convServ) {
rv = convServ->CanConvert("application/x-shockwave-flash",
"text/html", &canConvert);
}
return NS_SUCCEEDED(rv) && canConvert;
}
already_AddRefed<nsIDocumentLoaderFactory>
nsContentUtils::FindInternalContentViewer(const nsACString& aType,
ContentViewerType* aLoaderType)

View File

@ -2107,6 +2107,11 @@ public:
*/
static bool IsPDFJSEnabled();
/**
* Checks if internal SWF player is enabled.
*/
static bool IsSWFPlayerEnabled();
enum ContentViewerType
{
TYPE_UNSUPPORTED,

View File

@ -558,6 +558,11 @@ IsPluginEnabledByExtension(nsIURI* uri, nsCString& mimeType)
return false;
}
// Disables any native SWF plugins, when internal SWF player is enabled.
if (ext.EqualsIgnoreCase("swf") && nsContentUtils::IsSWFPlayerEnabled()) {
return false;
}
nsRefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
if (!pluginHost) {
@ -2689,6 +2694,13 @@ nsObjectLoadingContent::GetTypeOfContent(const nsCString& aMIMEType)
return eType_Document;
}
// Faking support of the SWF content as a document for EMBED tags
// when internal SWF player is enabled.
if (aMIMEType.LowerCaseEqualsLiteral("application/x-shockwave-flash") &&
nsContentUtils::IsSWFPlayerEnabled()) {
return eType_Document;
}
// SVGs load as documents, but are their own capability
bool isSVG = aMIMEType.LowerCaseEqualsLiteral("image/svg+xml");
Capabilities supportType = isSVG ? eSupportSVG : eSupportDocuments;