Bug 419582: Unblocklisted plugin should be set to enable on startup. r+sr=jst

This commit is contained in:
dtownsend@oxymoronical.com 2008-03-18 03:38:15 -07:00
Родитель b46aebb468
Коммит fec1f1442c
5 изменённых файлов: 68 добавлений и 59 удалений

Просмотреть файл

@ -9225,14 +9225,6 @@ nsNavigator::JavaEnabled(PRBool *aReturn)
*aReturn = PR_FALSE;
#ifdef OJI
// determine whether user has enabled java.
// if pref doesn't exist, map result to false.
*aReturn = nsContentUtils::GetBoolPref("security.enable_java");
// if Java is not enabled, result is false and return reight away
if (!*aReturn)
return NS_OK;
// Ask the nsIJVMManager if Java is enabled
nsCOMPtr<nsIJVMManager> jvmService = do_GetService(kJVMServiceCID);
if (jvmService) {

Просмотреть файл

@ -83,9 +83,7 @@
#include "nsIStringBundle.h"
#include "nsIObserver.h"
#include "nsIPrefBranch.h"
#include "nsIPrefBranch2.h"
#include "nsIPrefService.h"
#include "nsIObserverService.h"
#include "lcglue.h"
#include "nspr.h"
@ -94,6 +92,7 @@
#include "nsIPrincipal.h"
#include "nsIScriptSecurityManager.h"
#include "nsISignatureVerifier.h"
#include "nsSupportsPrimitives.h"
extern "C" int XP_PROGRESS_STARTING_JAVA;
@ -384,26 +383,37 @@ nsJVMManager::PostEvent(PRThread* prthread, nsIRunnable* runnable, PRBool async)
}
nsJVMManager::nsJVMManager(nsISupports* outer)
: fJVM(NULL), fStatus(nsJVMStatus_Enabled),
: fJVM(NULL), fStatus(nsJVMStatus_Disabled),
fDebugManager(NULL), fJSJavaVM(NULL),
fClassPathAdditions(new nsVoidArray()), fClassPathAdditionsString(NULL),
fStartupMessagePosted(PR_FALSE)
{
NS_INIT_AGGREGATED(outer);
nsCOMPtr<nsIPrefBranch2> branch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (branch) {
branch->AddObserver("security.enable_java", this, PR_FALSE);
PRBool prefBool = PR_TRUE;
nsresult rv = branch->GetBoolPref("security.enable_java", &prefBool);
if (NS_SUCCEEDED(rv)) {
SetJVMEnabled(prefBool);
nsCOMPtr<nsIPluginHost> host = do_GetService(kPluginManagerCID);
if (host) {
if (NS_SUCCEEDED(host->IsPluginEnabledForType(NS_JVM_MIME_TYPE))) {
SetJVMEnabled(PR_TRUE);
}
}
nsCOMPtr<nsIObserverService>
obsService(do_GetService("@mozilla.org/observer-service;1"));
if (obsService) {
obsService->AddObserver(this, NS_XPCOM_CATEGORY_ENTRY_ADDED_OBSERVER_ID, PR_FALSE);
obsService->AddObserver(this, NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID, PR_FALSE);
}
}
nsJVMManager::~nsJVMManager()
{
nsCOMPtr<nsIObserverService>
obsService(do_GetService("@mozilla.org/observer-service;1"));
if (obsService) {
obsService->RemoveObserver(this, NS_XPCOM_CATEGORY_ENTRY_ADDED_OBSERVER_ID);
obsService->RemoveObserver(this, NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID);
}
int count = fClassPathAdditions->Count();
for (int i = 0; i < count; i++) {
PR_Free((*fClassPathAdditions)[i]);
@ -844,17 +854,21 @@ nsJVMManager::Observe(nsISupports* subject,
const char* topic,
const PRUnichar* data_unicode)
{
nsresult rv;
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(subject, &rv);
if (NS_FAILED(rv)) return rv;
PRBool prefBool = PR_TRUE;
rv = branch->GetBoolPref("security.enable_java", &prefBool);
if (NS_SUCCEEDED(rv)) {
SetJVMEnabled(prefBool);
if (nsDependentString(data_unicode).Equals(NS_LITERAL_STRING("Gecko-Content-Viewers"))) {
nsCString mimeType;
nsCOMPtr<nsISupportsCString> type = do_QueryInterface(subject);
nsresult rv = type->GetData(mimeType);
NS_ENSURE_SUCCESS(rv, rv);
if (mimeType.Equals(NS_JVM_MIME_TYPE)) {
if (strcmp(topic, NS_XPCOM_CATEGORY_ENTRY_ADDED_OBSERVER_ID) == 0) {
SetJVMEnabled(PR_TRUE);
}
else if (strcmp(topic, NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID) == 0) {
SetJVMEnabled(PR_FALSE);
}
}
}
return rv;
return NS_OK;
}
nsJVMStatus

Просмотреть файл

@ -1075,11 +1075,9 @@ nsPluginTag::SetBlocklisted(PRBool aBlocklisted)
if (HasFlag(NS_PLUGIN_FLAG_BLOCKLISTED) == aBlocklisted)
return NS_OK;
if (aBlocklisted) {
if (aBlocklisted)
Mark(NS_PLUGIN_FLAG_BLOCKLISTED);
if (HasFlag(NS_PLUGIN_FLAG_ENABLED))
UnMark(NS_PLUGIN_FLAG_ENABLED);
} else
else
UnMark(NS_PLUGIN_FLAG_BLOCKLISTED);
mPluginHost->UpdatePluginInfo(nsnull);
@ -3531,7 +3529,7 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateEmbeddedPlugin(const char *aMimeType,
// disabled, we don't want to go on and end up in SetUpDefaultPluginInstance.
nsPluginTag* pluginTag = FindPluginForType(aMimeType, PR_FALSE);
if (pluginTag) {
if (!pluginTag->HasFlag(NS_PLUGIN_FLAG_ENABLED)) {
if (!pluginTag->IsEnabled()) {
return NS_ERROR_NOT_AVAILABLE;
}
} else if (!mJavaEnabled && IsJavaMIMEType(aMimeType)) {
@ -4217,13 +4215,7 @@ nsPluginHostImpl::IsPluginEnabledForType(const char* aMimeType)
return NS_ERROR_FAILURE;
}
if (!mJavaEnabled && IsJavaMIMEType(aMimeType)) {
// Return DISABLED whether we have a java plugin or not -- if it's
// disabled, it's disabled.
return NS_ERROR_PLUGIN_DISABLED;
}
if (!plugin->HasFlag(NS_PLUGIN_FLAG_ENABLED)) {
if (!plugin->IsEnabled()) {
if (plugin->HasFlag(NS_PLUGIN_FLAG_BLOCKLISTED))
return NS_ERROR_PLUGIN_BLOCKLISTED;
else
@ -4431,7 +4423,7 @@ nsPluginHostImpl::GetPluginCount(PRUint32* aPluginCount)
nsPluginTag* plugin = mPlugins;
while (plugin != nsnull) {
if (plugin->HasFlag(NS_PLUGIN_FLAG_ENABLED)) {
if (plugin->IsEnabled()) {
++count;
}
plugin = plugin->mNext;
@ -4451,7 +4443,7 @@ nsPluginHostImpl::GetPlugins(PRUint32 aPluginCount, nsIDOMPlugin** aPluginArray)
nsPluginTag* plugin = mPlugins;
for (PRUint32 i = 0; i < aPluginCount && plugin; plugin = plugin->mNext) {
if (plugin->HasFlag(NS_PLUGIN_FLAG_ENABLED)) {
if (plugin->IsEnabled()) {
nsIDOMPlugin* domPlugin = new DOMPluginImpl(plugin);
NS_IF_ADDREF(domPlugin);
aPluginArray[i++] = domPlugin;
@ -4511,7 +4503,7 @@ nsPluginHostImpl::FindPluginForType(const char* aMimeType,
variants = plugins->mVariants;
for (cnt = 0; cnt < variants; cnt++) {
if ((!aCheckEnabled || plugins->HasFlag(NS_PLUGIN_FLAG_ENABLED)) &&
if ((!aCheckEnabled || plugins->IsEnabled()) &&
plugins->mMimeTypeArray[cnt] &&
(0 == PL_strcasecmp(plugins->mMimeTypeArray[cnt], aMimeType))) {
return plugins;
@ -4550,7 +4542,7 @@ nsPluginHostImpl::FindPluginEnabledForExtension(const char* aExtension,
{
// mExtensionsArray[cnt] is a list of extensions separated
// by commas
if (plugins->HasFlag(NS_PLUGIN_FLAG_ENABLED) &&
if (plugins->IsEnabled() &&
0 == CompareExtensions(plugins->mExtensionsArray[cnt], aExtension))
{
aMimeType = plugins->mMimeTypeArray[cnt];
@ -5258,7 +5250,8 @@ nsresult nsPluginHostImpl::ScanPluginsDirectory(nsIFile * pluginsDir,
pluginTag->mNext = mPlugins;
mPlugins = pluginTag;
pluginTag->RegisterWithCategoryManager(mOverrideInternalTypes);
if (pluginTag->IsEnabled())
pluginTag->RegisterWithCategoryManager(mOverrideInternalTypes);
}
else if (!pluginTag->HasFlag(NS_PLUGIN_FLAG_UNWANTED)) {
// we don't need it, delete it;
@ -5552,7 +5545,7 @@ nsPluginHostImpl::UpdatePluginInfo(nsPluginTag* aPluginTag)
WritePluginInfo();
mCachedPlugins = nsnull;
if (!aPluginTag || aPluginTag->HasFlag(NS_PLUGIN_FLAG_ENABLED))
if (!aPluginTag || aPluginTag->IsEnabled())
return NS_OK;
nsCOMPtr<nsISupportsArray> instsToReload;
@ -6997,7 +6990,8 @@ nsPluginHostImpl::ScanForRealInComponentsFolder(nsIComponentManager * aCompManag
mPlugins = pluginTag;
// last thing we need is to register this plugin with layout so it can be used in full-page mode
pluginTag->RegisterWithCategoryManager(mOverrideInternalTypes);
if (pluginTag->IsEnabled())
pluginTag->RegisterWithCategoryManager(mOverrideInternalTypes);
}
}

Просмотреть файл

@ -117,24 +117,31 @@ public:
void SetHost(nsPluginHostImpl * aHost);
void TryUnloadPlugin(PRBool aForceShutdown = PR_FALSE);
void Mark(PRUint32 mask) {
PRBool wasEnabled = IsEnabled();
mFlags |= mask;
// Add mime types to the category manager only if we were made
// 'active' by setting the host
if ((mask & NS_PLUGIN_FLAG_ENABLED) && mPluginHost) {
RegisterWithCategoryManager(PR_FALSE, nsPluginTag::ePluginRegister);
// Update entries in the category manager if necessary.
if (mPluginHost && wasEnabled != IsEnabled()) {
if (wasEnabled)
RegisterWithCategoryManager(PR_FALSE, nsPluginTag::ePluginUnregister);
else
RegisterWithCategoryManager(PR_FALSE, nsPluginTag::ePluginRegister);
}
}
void UnMark(PRUint32 mask) {
PRBool wasEnabled = IsEnabled();
mFlags &= ~mask;
// Remove mime types added to the category manager only if we were
// made 'active' by setting the host
if ((mask & NS_PLUGIN_FLAG_ENABLED) && mPluginHost) {
RegisterWithCategoryManager(PR_FALSE, nsPluginTag::ePluginUnregister);
// Update entries in the category manager if necessary.
if (mPluginHost && wasEnabled != IsEnabled()) {
if (wasEnabled)
RegisterWithCategoryManager(PR_FALSE, nsPluginTag::ePluginUnregister);
else
RegisterWithCategoryManager(PR_FALSE, nsPluginTag::ePluginRegister);
}
}
PRBool HasFlag(PRUint32 flag) { return (mFlags & flag) != 0; }
PRUint32 Flags() { return mFlags; }
PRBool Equals(nsPluginTag* aPluginTag);
PRBool IsEnabled() { return HasFlag(NS_PLUGIN_FLAG_ENABLED) && !HasFlag(NS_PLUGIN_FLAG_BLOCKLISTED); }
enum nsRegisterType {
ePluginRegister,

Просмотреть файл

@ -951,7 +951,8 @@ function rebuildPluginsDS()
true);
gPluginsDS.Assert(pluginNode,
gRDF.GetResource(PREFIX_NS_EM + "isDisabled"),
gRDF.GetLiteral(plugin.disabled ? "true" : "false"),
gRDF.GetLiteral((plugin.disabled ||
plugin.blocklisted) ? "true" : "false"),
true);
gPluginsDS.Assert(pluginNode,
gRDF.GetResource(PREFIX_NS_EM + "blocklisted"),
@ -977,10 +978,11 @@ function togglePluginDisabled(aName, aDesc)
plugin.disabled = !plugin.disabled;
for (var i = 0; i < plugin.plugins.length; ++i)
plugin.plugins[i].disabled = plugin.disabled;
var isDisabled = plugin.disabled || plugin.blocklisted;
gPluginsDS.Change(gRDF.GetResource(PREFIX_ITEM_URI + plugin.filename),
gRDF.GetResource(PREFIX_NS_EM + "isDisabled"),
gRDF.GetLiteral(plugin.disabled ? "false" : "true"),
gRDF.GetLiteral(plugin.disabled ? "true" : "false"));
gRDF.GetLiteral(isDisabled ? "false" : "true"),
gRDF.GetLiteral(isDisabled ? "true" : "false"));
gExtensionsViewController.onCommandUpdate();
gExtensionsView.selectedItem.focus();
}