mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1282484 - Add a mechanism to control plugin fallback content. r=qDot
MozReview-Commit-ID: Lt4tOdFdQzN
This commit is contained in:
parent
2b44bf8c6e
commit
917ff060cb
@ -109,6 +109,7 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
static const char *kPrefJavaMIME = "plugin.java.mime";
|
||||
static const char *kPrefYoutubeRewrite = "plugins.rewrite_youtube_embeds";
|
||||
static const char *kPrefBlockURIs = "browser.safebrowsing.blockedURIs.enabled";
|
||||
static const char *kPrefFavorFallbackMode = "plugins.favorfallback.mode";
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -3372,11 +3373,22 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
|
||||
}
|
||||
switch (permission) {
|
||||
case nsIPermissionManager::ALLOW_ACTION:
|
||||
if (PreferFallback(false /* isPluginClickToPlay */)) {
|
||||
aReason = eFallbackAlternate;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
case nsIPermissionManager::DENY_ACTION:
|
||||
aReason = eFallbackDisabled;
|
||||
return false;
|
||||
case nsIPermissionManager::PROMPT_ACTION:
|
||||
if (PreferFallback(true /* isPluginClickToPlay */)) {
|
||||
// False is already returned in this case, but
|
||||
// it's important to correctly set aReason too.
|
||||
aReason = eFallbackAlternate;
|
||||
}
|
||||
|
||||
return false;
|
||||
case nsIPermissionManager::UNKNOWN_ACTION:
|
||||
break;
|
||||
@ -3392,6 +3404,11 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PreferFallback(enabledState == nsIPluginTag::STATE_CLICKTOPLAY)) {
|
||||
aReason = eFallbackAlternate;
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (enabledState) {
|
||||
case nsIPluginTag::STATE_ENABLED:
|
||||
return true;
|
||||
@ -3401,6 +3418,48 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
|
||||
MOZ_CRASH("Unexpected enabledState");
|
||||
}
|
||||
|
||||
bool
|
||||
nsObjectLoadingContent::FavorFallbackMode(bool aIsPluginClickToPlay) {
|
||||
if (!IsFlashMIME(mContentType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCString prefString;
|
||||
if (NS_SUCCEEDED(Preferences::GetCString(kPrefFavorFallbackMode, &prefString))) {
|
||||
if (aIsPluginClickToPlay &&
|
||||
prefString.EqualsLiteral("follow-ctp")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (prefString.EqualsLiteral("always")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
nsObjectLoadingContent::HasGoodFallback() {
|
||||
nsCOMPtr<nsIContent> thisContent =
|
||||
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
||||
NS_ASSERTION(thisContent, "must be a content");
|
||||
|
||||
if (!thisContent->IsHTMLElement(nsGkAtoms::object) ||
|
||||
mContentType.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// xxx to be filled
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
nsObjectLoadingContent::PreferFallback(bool aIsPluginClickToPlay) {
|
||||
return FavorFallbackMode(aIsPluginClickToPlay) && HasGoodFallback();
|
||||
}
|
||||
|
||||
nsIDocument*
|
||||
nsObjectLoadingContent::GetContentDocument(nsIPrincipal& aSubjectPrincipal)
|
||||
{
|
||||
|
@ -460,6 +460,32 @@ class nsObjectLoadingContent : public nsImageLoadingContent
|
||||
*/
|
||||
bool ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentType);
|
||||
|
||||
/**
|
||||
* This method tells if the fallback content should be attempted to be used
|
||||
* over the original object content.
|
||||
* It will look at prefs and this plugin's CTP state to make a decision.
|
||||
*
|
||||
* NOTE that this doesn't say whether the fallback _will_ be used, only whether
|
||||
* we should look into it to possibly use it. The final answer will be
|
||||
* given by the PreferFallback method.
|
||||
*
|
||||
* @param aIsPluginClickToPlay Whether this object instance is CTP.
|
||||
*/
|
||||
bool FavorFallbackMode(bool aIsPluginClickToPlay);
|
||||
|
||||
/**
|
||||
* Whether the page has provided good fallback content to this object.
|
||||
*/
|
||||
bool HasGoodFallback();
|
||||
|
||||
/**
|
||||
* This method tells the final answer on whether this object's fallback
|
||||
* content should be used instead of the original plugin content.
|
||||
*
|
||||
* @param aIsPluginClickToPlay Whether this object instance is CTP.
|
||||
*/
|
||||
bool PreferFallback(bool aIsPluginClickToPlay);
|
||||
|
||||
/*
|
||||
* Helper to check if mBaseURI can be used by java as a codebase
|
||||
*/
|
||||
|
@ -2824,6 +2824,14 @@ pref("plugin.sessionPermissionNow.intervalInMinutes", 60);
|
||||
// to allow it persistently.
|
||||
pref("plugin.persistentPermissionAlways.intervalInDays", 90);
|
||||
|
||||
// This pref can take 3 possible string values:
|
||||
// "always" - always use favor fallback mode
|
||||
// "follow-ctp" - activate if ctp is active for the given
|
||||
// plugin object (could be due to a plugin-wide
|
||||
// setting or a site-specific setting)
|
||||
// "never" - never use favor fallback mode
|
||||
pref("plugins.favorfallback.mode", "never");
|
||||
|
||||
// Set IPC timeouts for plugins and tabs, except in leak-checking and
|
||||
// dynamic analysis builds. (NS_FREE_PERMANENT_DATA is C++ only, so
|
||||
// approximate its definition here.)
|
||||
|
Loading…
Reference in New Issue
Block a user