Bug 1237402 - Allow certain plugins to be loaded in parent process (r=jimm)

This commit is contained in:
Bill McCloskey 2016-01-05 17:57:11 -08:00
parent 7eccfdbfa9
commit e73c8838c9
3 changed files with 25 additions and 6 deletions

View File

@ -3276,12 +3276,17 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
sPrefsInitialized = true;
}
if (XRE_IsParentProcess() &&
BrowserTabsRemoteAutostart()) {
// Plugins running OOP from the chrome process along with plugins running
// OOP from the content process will hang. Let's prevent that situation.
aReason = eFallbackDisabled;
return false;
if (BrowserTabsRemoteAutostart()) {
bool shouldLoadInParent = nsPluginHost::ShouldLoadTypeInParent(mContentType);
bool inParent = XRE_IsParentProcess();
if (shouldLoadInParent != inParent) {
// Plugins need to be locked to either the parent process or the content
// process. If a plugin is locked to one process type, it can't be used in
// the other. Otherwise we'll get hangs.
aReason = eFallbackDisabled;
return false;
}
}
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();

View File

@ -137,6 +137,7 @@ using mozilla::dom::FakePluginTagInit;
#define kPluginTmpDirName NS_LITERAL_CSTRING("plugtmp")
static const char *kPrefWhitelist = "plugin.allowed_types";
static const char *kPrefLoadInParentPrefix = "plugin.load_in_parent_process.";
static const char *kPrefDisableFullPage = "plugin.disable_full_page_plugin_for_types";
static const char *kPrefJavaMIME = "plugin.java.mime";
@ -2762,6 +2763,14 @@ nsPluginHost::IsTypeWhitelisted(const char *aMimeType)
return IsTypeInList(wrap, whitelist);
}
/* static */ bool
nsPluginHost::ShouldLoadTypeInParent(const nsACString& aMimeType)
{
nsCString prefName(kPrefLoadInParentPrefix);
prefName += aMimeType;
return Preferences::GetBool(prefName.get(), false);
}
void
nsPluginHost::RegisterWithCategoryManager(const nsCString& aMimeType,
nsRegisterType aType)

View File

@ -189,6 +189,11 @@ public:
// Always returns true if plugin.allowed_types is not set
static bool IsTypeWhitelisted(const char *aType);
// Helper that checks if a plugin of a given MIME type can be loaded by the
// parent process. It checks the plugin.load_in_parent_process.<mime> pref.
// Always returns false if plugin.load_in_parent_process.<mime> is not set.
static bool ShouldLoadTypeInParent(const nsACString& aMimeType);
// checks whether aType is a type we recognize for potential special handling
enum SpecialType { eSpecialType_None,
// Needed to whitelist for async init support