Remove MailNews special casing from nsScriptSecurityManager (bug 374577), r+sr=bzbarsky

This commit is contained in:
Dan Mosedale 2009-02-17 20:32:57 -08:00
parent 9f57918e8c
commit e4aa8b0d67
3 changed files with 12 additions and 35 deletions

View File

@ -575,7 +575,6 @@ private:
ScriptSecurityPrefChanged();
static const char sJSEnabledPrefName[];
static const char sJSMailEnabledPrefName[];
static const char sFileOriginPolicyPrefName[];
nsObjectHashtable* mOriginToPolicyMap;
@ -588,7 +587,6 @@ private:
nsCOMPtr<nsIPrincipal> mSystemCertificate;
nsInterfaceHashtable<PrincipalKey, nsIPrincipal> mPrincipals;
PRPackedBool mIsJavaScriptEnabled;
PRPackedBool mIsMailJavaScriptEnabled;
PRPackedBool mIsWritingPrefs;
PRPackedBool mPolicyPrefsChanged;
#ifdef XPC_IDISPATCH_SUPPORT

View File

@ -1752,26 +1752,7 @@ nsScriptSecurityManager::CanExecuteScripts(JSContext* cx,
}
}
//-- See if JS is disabled globally (via prefs)
*result = mIsJavaScriptEnabled;
if (mIsJavaScriptEnabled != mIsMailJavaScriptEnabled && globalObjTreeItem)
{
nsCOMPtr<nsIDocShellTreeItem> rootItem;
globalObjTreeItem->GetRootTreeItem(getter_AddRefs(rootItem));
docshell = do_QueryInterface(rootItem);
if (docshell)
{
// Is this script running from mail?
PRUint32 appType;
rv = docshell->GetAppType(&appType);
if (NS_FAILED(rv)) return rv;
if (appType == nsIDocShell::APP_TYPE_MAIL)
{
*result = mIsMailJavaScriptEnabled;
}
}
}
if (!*result)
return NS_OK; // Do not run scripts
@ -3214,7 +3195,6 @@ nsScriptSecurityManager::nsScriptSecurityManager(void)
mDefaultPolicy(nsnull),
mCapabilities(nsnull),
mIsJavaScriptEnabled(PR_FALSE),
mIsMailJavaScriptEnabled(PR_FALSE),
mIsWritingPrefs(PR_FALSE),
mPolicyPrefsChanged(PR_TRUE)
#ifdef XPC_IDISPATCH_SUPPORT
@ -3814,8 +3794,6 @@ nsScriptSecurityManager::InitPrincipals(PRUint32 aPrefCount, const char** aPrefN
const char nsScriptSecurityManager::sJSEnabledPrefName[] =
"javascript.enabled";
const char nsScriptSecurityManager::sJSMailEnabledPrefName[] =
"javascript.allow.mailnews";
const char nsScriptSecurityManager::sFileOriginPolicyPrefName[] =
"security.fileuri.strict_origin_policy";
#ifdef XPC_IDISPATCH_SUPPORT
@ -3829,9 +3807,6 @@ nsScriptSecurityManager::ScriptSecurityPrefChanged()
// JavaScript defaults to enabled in failure cases.
mIsJavaScriptEnabled = PR_TRUE;
// JavaScript in Mail defaults to disabled in failure cases.
mIsMailJavaScriptEnabled = PR_FALSE;
sStrictFileOriginPolicy = PR_TRUE;
#ifdef XPC_IDISPATCH_SUPPORT
@ -3851,13 +3826,6 @@ nsScriptSecurityManager::ScriptSecurityPrefChanged()
if (NS_SUCCEEDED(rv))
mIsJavaScriptEnabled = temp;
// JavaScript in mailnews is disabled until quickstubs and CAPS work
// together or we find an alternative to CAPS: see bug 374577 or
// bug 453928 or bug 453943.
// rv = mSecurityPref->SecurityGetBoolPref(sJSMailEnabledPrefName, &temp);
// if (NS_SUCCEEDED(rv))
// mIsMailJavaScriptEnabled = temp;
rv = mSecurityPref->SecurityGetBoolPref(sFileOriginPolicyPrefName, &temp);
if (NS_SUCCEEDED(rv))
sStrictFileOriginPolicy = NS_SUCCEEDED(rv) && temp;
@ -3886,7 +3854,6 @@ nsScriptSecurityManager::InitPrefs()
ScriptSecurityPrefChanged();
// set observer callbacks in case the value of the prefs change
prefBranchInternal->AddObserver(sJSEnabledPrefName, this, PR_FALSE);
prefBranchInternal->AddObserver(sJSMailEnabledPrefName, this, PR_FALSE);
prefBranchInternal->AddObserver(sFileOriginPolicyPrefName, this, PR_FALSE);
#ifdef XPC_IDISPATCH_SUPPORT
prefBranchInternal->AddObserver(sXPCDefaultGrantAllName, this, PR_FALSE);

View File

@ -261,8 +261,20 @@ NS_CheckContentProcessPolicy(PRUint32 contentType,
* will be returned.
*
* @param aContext the context to find a docshell for (can be null)
*
* @return a WEAK pointer to the docshell, or nsnull if it could
* not be obtained
*
* @note As of this writing, calls to nsIContentPolicy::Should{Load,Process}
* for TYPE_DOCUMENT and TYPE_SUBDOCUMENT pass in an aContext that either
* points to the frameElement of the window the load is happening in
* (in which case NS_CP_GetDocShellFromContext will return the parent of the
* docshell the load is happening in), or points to the window the load is
* happening in (in which case NS_CP_GetDocShellFromContext will return
* the docshell the load is happening in). It's up to callers to QI aContext
* and handle things accordingly if they want the docshell the load is
* happening in. These are somewhat odd semantics, and bug 466687 has been
* filed to consider improving them.
*/
inline nsIDocShell*
NS_CP_GetDocShellFromContext(nsISupports *aContext)