зеркало из https://github.com/mozilla/gecko-dev.git
Bug 269661 make libpref not depend on caps
r=caillon sr=dveditz
This commit is contained in:
Родитель
edb2027179
Коммит
92c940aa45
|
@ -310,6 +310,7 @@ private:
|
|||
{ 0xba, 0x18, 0x00, 0x60, 0xb0, 0xf1, 0x99, 0xa2 }}
|
||||
|
||||
class nsScriptSecurityManager : public nsIScriptSecurityManager,
|
||||
public nsIPrefSecurityCheck,
|
||||
public nsIObserver
|
||||
{
|
||||
public:
|
||||
|
@ -320,6 +321,7 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTSECURITYMANAGER
|
||||
NS_DECL_NSIXPCSECURITYMANAGER
|
||||
NS_DECL_NSIPREFSECURITYCHECK
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
static nsScriptSecurityManager*
|
||||
|
|
|
@ -414,9 +414,10 @@ DeleteDomainEntry(nsHashKey *aKey, void *aData, void* closure)
|
|||
////////////////////////////////////
|
||||
// Methods implementing ISupports //
|
||||
////////////////////////////////////
|
||||
NS_IMPL_ISUPPORTS3(nsScriptSecurityManager,
|
||||
NS_IMPL_ISUPPORTS4(nsScriptSecurityManager,
|
||||
nsIScriptSecurityManager,
|
||||
nsIXPCSecurityManager,
|
||||
nsIPrefSecurityCheck,
|
||||
nsIObserver)
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
|
@ -2708,6 +2709,17 @@ nsScriptSecurityManager::CheckXPCPermissions(nsISupports* aObj,
|
|||
return NS_ERROR_DOM_XPCONNECT_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Method implementing nsIPrefSecurityCheck //
|
||||
//////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptSecurityManager::CanAccessSecurityPreferences(PRBool* _retval)
|
||||
{
|
||||
return IsCapabilityEnabled("CapabilityPreferencesAccess", _retval);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Method implementing nsIObserver //
|
||||
/////////////////////////////////////
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsXPIDLString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsPrefsCID.h"
|
||||
|
||||
///////////////////////
|
||||
// nsSecurityNameSet //
|
||||
|
@ -381,6 +382,20 @@ static const nsModuleComponentInfo capsComponentInfo[] =
|
|||
nsIClassInfo::MAIN_THREAD_ONLY
|
||||
},
|
||||
|
||||
{ NS_SCRIPTSECURITYMANAGER_CLASSNAME,
|
||||
NS_SCRIPTSECURITYMANAGER_CID,
|
||||
NS_GLOBAL_PREF_SECURITY_CHECK,
|
||||
Construct_nsIScriptSecurityManager,
|
||||
RegisterSecurityNameSet,
|
||||
nsnull,
|
||||
nsnull,
|
||||
nsnull,
|
||||
nsnull,
|
||||
nsnull,
|
||||
nsIClassInfo::MAIN_THREAD_ONLY
|
||||
},
|
||||
|
||||
|
||||
{ NS_PRINCIPAL_CLASSNAME,
|
||||
NS_PRINCIPAL_CID,
|
||||
NS_PRINCIPAL_CONTRACTID,
|
||||
|
|
|
@ -42,5 +42,9 @@ XPIDLSRCS = \
|
|||
nsIRelativeFilePref.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsPrefsCID.h \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -140,3 +140,18 @@ interface nsISecurityPref : nsISupports {
|
|||
void securityClearUserPref(in string pref_name);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* This interface allows checking whether getting capability prefs is allowed.
|
||||
*/
|
||||
[uuid(c73c9a05-92ce-46e1-8f69-90a2a3a36104)]
|
||||
interface nsIPrefSecurityCheck : nsISupports {
|
||||
/**
|
||||
* Checks whether the currently executing script (if any) can access security
|
||||
* preferences. Corresponds to CapabilityPreferencesAccess.
|
||||
*
|
||||
* Exceptions from this method should be treated like a return value of false.
|
||||
*/
|
||||
boolean canAccessSecurityPreferences();
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the prefs module contractid listing file.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christian Biesinger <cbiesinger@web.de>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef NSPREFSCID_H_
|
||||
#define NSPREFSCID_H_
|
||||
|
||||
/**
|
||||
* This service will be used by the prefs module when a preference of
|
||||
* capability.* is being requested. It is used to check whether the caller is
|
||||
* allowed to access this pref. canAccessSecurityPreferences is called to
|
||||
* determine that.
|
||||
*
|
||||
* INTERFACES THAT NEED TO BE IMPLEMENTED:
|
||||
* nsISupports
|
||||
* nsIPrefSecurityCheck
|
||||
*/
|
||||
#define NS_GLOBAL_PREF_SECURITY_CHECK "@mozilla.org/globalprefsecuritycheck;1"
|
||||
|
||||
#endif
|
|
@ -42,7 +42,6 @@ REQUIRES = xpcom \
|
|||
string \
|
||||
js \
|
||||
xpconnect \
|
||||
caps \
|
||||
intl \
|
||||
necko \
|
||||
$(NULL)
|
||||
|
|
|
@ -46,11 +46,11 @@
|
|||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "prefapi.h"
|
||||
#include "prmem.h"
|
||||
#include "pldhash.h"
|
||||
#include "nsPrefsCID.h"
|
||||
|
||||
#include "nsIFileSpec.h" // this should be removed eventually
|
||||
#include "prefapi_private_data.h"
|
||||
|
@ -810,7 +810,7 @@ nsresult nsPrefBranch::GetDefaultFromPropertiesFile(const char *aPrefName, PRUni
|
|||
|
||||
// string names are in unicode
|
||||
nsAutoString stringId;
|
||||
stringId.AssignWithConversion(aPrefName);
|
||||
stringId.AssignASCII(aPrefName);
|
||||
|
||||
return bundle->GetStringFromName(stringId.get(), return_buf);
|
||||
}
|
||||
|
@ -843,14 +843,14 @@ nsresult nsPrefBranch::getValidatedPrefName(const char *aPrefName, const char **
|
|||
PL_strncmp(fullPref, capabilityPrefix, sizeof(capabilityPrefix)-1) == 0)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
nsCOMPtr<nsIPrefSecurityCheck> secCheck =
|
||||
do_GetService(NS_GLOBAL_PREF_SECURITY_CHECK, &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool enabled;
|
||||
rv = secMan->IsCapabilityEnabled("CapabilityPreferencesAccess", &enabled);
|
||||
rv = secCheck->CanAccessSecurityPreferences(&enabled);
|
||||
if (NS_FAILED(rv) || !enabled)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче