Bug 971279 - Add plugin.java.mime. r=bsmedberg

This commit is contained in:
John Schoenick 2014-02-10 15:50:53 -08:00
parent b2a962217f
commit 78dc97b207
6 changed files with 35 additions and 25 deletions

View File

@ -33,14 +33,9 @@ var gPluginHandler = {
let fallbackType = null;
let blocklistState = null;
if (pluginElement instanceof HTMLAppletElement) {
tagMimetype = "application/x-java-vm";
} else {
tagMimetype = pluginElement.actualType;
if (tagMimetype == "") {
tagMimetype = pluginElement.type;
}
tagMimetype = pluginElement.actualType;
if (tagMimetype == "") {
tagMimetype = pluginElement.type;
}
if (gPluginHandler.isKnownPlugin(pluginElement)) {

View File

@ -92,6 +92,8 @@
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
static const char *kPrefJavaMIME = "plugin.java.mime";
using namespace mozilla;
using namespace mozilla::dom;
@ -1410,8 +1412,12 @@ nsObjectLoadingContent::UpdateObjectParameters(bool aJavaURI)
///
/// Initial MIME Type
///
if (aJavaURI || thisContent->NodeInfo()->Equals(nsGkAtoms::applet)) {
newMime.AssignLiteral("application/x-java-vm");
nsAdoptingCString javaMIME = Preferences::GetCString(kPrefJavaMIME);
newMime = javaMIME;
NS_ASSERTION(nsPluginHost::IsJavaMIMEType(newMime.get()),
"plugin.mime.java should be recognized by IsJavaMIMEType");
isJava = true;
} else {
nsAutoString rawTypeAttr;
@ -1432,9 +1438,12 @@ nsObjectLoadingContent::UpdateObjectParameters(bool aJavaURI)
thisContent->GetAttr(kNameSpaceID_None, nsGkAtoms::classid, classIDAttr);
if (!classIDAttr.IsEmpty()) {
// Our classid support is limited to 'java:' ids
nsAdoptingCString javaMIME = Preferences::GetCString(kPrefJavaMIME);
NS_ASSERTION(nsPluginHost::IsJavaMIMEType(javaMIME.get()),
"plugin.mime.java should be recognized by IsJavaMIMEType");
if (StringBeginsWith(classIDAttr, NS_LITERAL_STRING("java:")) &&
PluginExistsForType("application/x-java-vm")) {
newMime.Assign("application/x-java-vm");
PluginExistsForType(javaMIME)) {
newMime = javaMIME;
isJava = true;
} else {
// XXX(johns): Our de-facto behavior since forever was to refuse to load

View File

@ -576,8 +576,11 @@ bool
Navigator::JavaEnabled(ErrorResult& aRv)
{
Telemetry::AutoTimer<Telemetry::CHECK_JAVA_ENABLED> telemetryTimer;
// Return true if we have a handler for "application/x-java-vm",
// otherwise return false.
// Return true if we have a handler for the java mime
nsAdoptingString javaMIME = Preferences::GetString("plugin.java.mime");
NS_ENSURE_TRUE(!javaMIME.IsEmpty(), false);
if (!mMimeTypes) {
if (!mWindow) {
aRv.Throw(NS_ERROR_UNEXPECTED);
@ -588,8 +591,7 @@ Navigator::JavaEnabled(ErrorResult& aRv)
RefreshMIMEArray();
nsMimeType *mimeType =
mMimeTypes->NamedItem(NS_LITERAL_STRING("application/x-java-vm"));
nsMimeType *mimeType = mMimeTypes->NamedItem(javaMIME);
return mimeType && mimeType->GetEnabledPlugin();
}

View File

@ -124,6 +124,7 @@ using mozilla::TimeStamp;
static const char *kPrefWhitelist = "plugin.allowed_types";
static const char *kPrefDisableFullPage = "plugin.disable_full_page_plugin_for_types";
static const char *kPrefJavaMIME = "plugin.java.mime";
// Version of cached plugin info
// 0.01 first implementation
@ -1555,8 +1556,12 @@ nsPluginHost::SiteHasData(nsIPluginTag* plugin, const nsACString& domain,
bool nsPluginHost::IsJavaMIMEType(const char* aType)
{
// The java mime pref may well not be one of these,
// e.g. application/x-java-test used in the test suite
nsAdoptingCString javaMIME = Preferences::GetCString(kPrefJavaMIME);
return aType &&
((0 == PL_strncasecmp(aType, "application/x-java-vm",
(javaMIME.EqualsIgnoreCase(aType) ||
(0 == PL_strncasecmp(aType, "application/x-java-vm",
sizeof("application/x-java-vm") - 1)) ||
(0 == PL_strncasecmp(aType, "application/x-java-applet",
sizeof("application/x-java-applet") - 1)) ||

View File

@ -136,16 +136,10 @@ var PluginHelper = {
},
getPluginMimeType: function (plugin) {
var tagMimetype;
if (plugin instanceof HTMLAppletElement) {
tagMimetype = "application/x-java-vm";
} else {
tagMimetype = plugin.QueryInterface(Components.interfaces.nsIObjectLoadingContent)
.actualType;
var tagMimetype = plugin.actualType;
if (tagMimetype == "") {
tagMimetype = plugin.type;
}
if (tagMimetype == "") {
tagMimetype = plugin.type;
}
return tagMimetype;

View File

@ -1910,6 +1910,11 @@ pref("plugins.enumerable_names", "Java,Nexus Personal,QuickTime,Shockwave");
// The default value for nsIPluginTag.enabledState (STATE_ENABLED = 2)
pref("plugin.default.state", 2);
// The MIME type that should bind to legacy java-specific invocations like
// <applet> and <object data="java:foo">. Setting this to a non-java MIME type
// is undefined behavior.
pref("plugin.java.mime", "application/x-java-vm");
// How long in minutes we will allow a plugin to work after the user has chosen
// to allow it "now"
pref("plugin.sessionPermissionNow.intervalInMinutes", 60);