2007-03-22 10:30:00 -07:00
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2012-05-21 04:12:37 -07:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at http : //mozilla.org/MPL/2.0/. */
2007-03-22 10:30:00 -07:00
2010-07-19 11:33:33 -07:00
# include "mozilla/dom/ContentChild.h"
2010-05-25 17:13:47 -07:00
# include "nsXULAppAPI.h"
2007-03-22 10:30:00 -07:00
# include "nsPrefBranch.h"
2012-06-05 19:08:30 -07:00
# include "nsILocalFile.h" // nsILocalFile used for backwards compatibility
2007-03-22 10:30:00 -07:00
# include "nsIObserverService.h"
# include "nsXPCOM.h"
# include "nsISupportsPrimitives.h"
# include "nsIDirectoryService.h"
# include "nsString.h"
# include "nsReadableUtils.h"
# include "nsXPIDLString.h"
2013-03-08 09:27:58 -08:00
# include "nsPrintfCString.h"
2007-03-22 10:30:00 -07:00
# include "nsIStringBundle.h"
# include "prefapi.h"
# include "pldhash.h"
# include "nsCRT.h"
Bug 560095 - Use mozilla::services::GetObserverService(). r=biesi,dveditz,gavin,josh,jst,mrbkap,roc,sdwilsh,shaver,sicking,smontagu,surkov
2010-04-29 09:59:13 -07:00
# include "mozilla/Services.h"
2007-03-22 10:30:00 -07:00
# include "prefapi_private_data.h"
2013-03-08 09:27:58 -08:00
# ifdef MOZ_CRASHREPORTER
# include "nsICrashReporter.h"
# endif
2013-06-04 05:21:06 -07:00
# include "nsIConsoleService.h"
2013-12-03 15:18:09 -08:00
# ifdef DEBUG
# define ENSURE_MAIN_PROCESS(message, pref) do { \
if ( GetContentChild ( ) ) { \
nsPrintfCString msg ( " ENSURE_MAIN_PROCESS failed. %s %s " , message , pref ) ; \
NS_ERROR ( msg . get ( ) ) ; \
return NS_ERROR_NOT_AVAILABLE ; \
} \
} while ( 0 ) ;
# else
# define ENSURE_MAIN_PROCESS(message, pref) \
if ( GetContentChild ( ) ) { \
return NS_ERROR_NOT_AVAILABLE ; \
}
# endif
2007-03-22 10:30:00 -07:00
// Definitions
struct EnumerateData {
const char * parent ;
2010-05-28 11:09:15 -07:00
nsTArray < nsCString > * pref_list ;
2007-03-22 10:30:00 -07:00
} ;
// Prototypes
2008-10-10 08:04:34 -07:00
static PLDHashOperator
2007-03-22 10:30:00 -07:00
pref_enumChild ( PLDHashTable * table , PLDHashEntryHdr * heh ,
2012-08-22 08:56:38 -07:00
uint32_t i , void * arg ) ;
2007-03-22 10:30:00 -07:00
2010-07-19 11:33:33 -07:00
using mozilla : : dom : : ContentChild ;
2010-07-02 20:03:18 -07:00
2010-07-19 11:33:33 -07:00
static ContentChild *
GetContentChild ( )
2010-07-02 20:03:18 -07:00
{
if ( XRE_GetProcessType ( ) = = GeckoProcessType_Content ) {
2010-07-19 11:33:33 -07:00
ContentChild * cpc = ContentChild : : GetSingleton ( ) ;
2010-07-02 20:03:18 -07:00
if ( ! cpc ) {
NS_RUNTIMEABORT ( " Content Protocol is NULL! We're going to crash! " ) ;
}
return cpc ;
}
2012-07-30 07:20:58 -07:00
return nullptr ;
2010-07-02 20:03:18 -07:00
}
2007-03-22 10:30:00 -07:00
/*
* Constructor / Destructor
*/
2011-09-28 23:19:26 -07:00
nsPrefBranch : : nsPrefBranch ( const char * aPrefRoot , bool aDefaultBranch )
2007-03-22 10:30:00 -07:00
{
mPrefRoot = aPrefRoot ;
mPrefRootLength = mPrefRoot . Length ( ) ;
mIsDefault = aDefaultBranch ;
2011-10-17 07:59:28 -07:00
mFreeingObserverList = false ;
2007-03-22 10:30:00 -07:00
Bug 560095 - Use mozilla::services::GetObserverService(). r=biesi,dveditz,gavin,josh,jst,mrbkap,roc,sdwilsh,shaver,sicking,smontagu,surkov
2010-04-29 09:59:13 -07:00
nsCOMPtr < nsIObserverService > observerService =
mozilla : : services : : GetObserverService ( ) ;
2007-03-22 10:30:00 -07:00
if ( observerService ) {
+ + mRefCnt ; // Our refcnt must be > 0 when we call this, or we'll get deleted!
// add weak so we don't have to clean up at shutdown
2011-10-17 07:59:28 -07:00
observerService - > AddObserver ( this , NS_XPCOM_SHUTDOWN_OBSERVER_ID , true ) ;
2007-03-22 10:30:00 -07:00
- - mRefCnt ;
}
}
nsPrefBranch : : ~ nsPrefBranch ( )
{
freeObserverList ( ) ;
2010-11-04 13:06:05 -07:00
nsCOMPtr < nsIObserverService > observerService =
mozilla : : services : : GetObserverService ( ) ;
if ( observerService )
observerService - > RemoveObserver ( this , NS_XPCOM_SHUTDOWN_OBSERVER_ID ) ;
2007-03-22 10:30:00 -07:00
}
/*
* nsISupports Implementation
*/
2013-07-18 19:23:44 -07:00
NS_IMPL_ADDREF ( nsPrefBranch )
NS_IMPL_RELEASE ( nsPrefBranch )
2007-03-22 10:30:00 -07:00
NS_INTERFACE_MAP_BEGIN ( nsPrefBranch )
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS ( nsISupports , nsIPrefBranch )
NS_INTERFACE_MAP_ENTRY ( nsIPrefBranch )
NS_INTERFACE_MAP_ENTRY_CONDITIONAL ( nsIPrefBranch2 , ! mIsDefault )
NS_INTERFACE_MAP_ENTRY_CONDITIONAL ( nsIPrefBranchInternal , ! mIsDefault )
NS_INTERFACE_MAP_ENTRY ( nsIObserver )
NS_INTERFACE_MAP_ENTRY ( nsISupportsWeakReference )
NS_INTERFACE_MAP_END
/*
* nsIPrefBranch Implementation
*/
2010-05-25 17:13:47 -07:00
NS_IMETHODIMP nsPrefBranch : : GetRoot ( char * * aRoot )
2007-03-22 10:30:00 -07:00
{
NS_ENSURE_ARG_POINTER ( aRoot ) ;
mPrefRoot . Truncate ( mPrefRootLength ) ;
* aRoot = ToNewCString ( mPrefRoot ) ;
return NS_OK ;
}
2012-08-22 08:56:38 -07:00
NS_IMETHODIMP nsPrefBranch : : GetPrefType ( const char * aPrefName , int32_t * _retval )
2007-03-22 10:30:00 -07:00
{
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aPrefName ) ;
2007-03-22 10:30:00 -07:00
* _retval = PREF_GetPrefType ( pref ) ;
return NS_OK ;
}
2011-09-28 23:19:26 -07:00
NS_IMETHODIMP nsPrefBranch : : GetBoolPref ( const char * aPrefName , bool * _retval )
2007-03-22 10:30:00 -07:00
{
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aPrefName ) ;
return PREF_GetBoolPref ( pref , _retval , mIsDefault ) ;
2007-03-22 10:30:00 -07:00
}
2011-09-28 23:19:26 -07:00
NS_IMETHODIMP nsPrefBranch : : SetBoolPref ( const char * aPrefName , bool aValue )
2007-03-22 10:30:00 -07:00
{
2013-12-03 15:18:09 -08:00
ENSURE_MAIN_PROCESS ( " Cannot SetBoolPref from content process: " , aPrefName ) ;
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aPrefName ) ;
return PREF_SetBoolPref ( pref , aValue , mIsDefault ) ;
2007-03-22 10:30:00 -07:00
}
2012-09-26 13:53:37 -07:00
NS_IMETHODIMP nsPrefBranch : : GetFloatPref ( const char * aPrefName , float * _retval )
{
NS_ENSURE_ARG ( aPrefName ) ;
const char * pref = getPrefName ( aPrefName ) ;
nsAutoCString stringVal ;
nsresult rv = GetCharPref ( pref , getter_Copies ( stringVal ) ) ;
if ( NS_SUCCEEDED ( rv ) ) {
* _retval = stringVal . ToFloat ( & rv ) ;
}
return rv ;
}
2007-03-22 10:30:00 -07:00
NS_IMETHODIMP nsPrefBranch : : GetCharPref ( const char * aPrefName , char * * _retval )
{
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aPrefName ) ;
return PREF_CopyCharPref ( pref , _retval , mIsDefault ) ;
2007-03-22 10:30:00 -07:00
}
NS_IMETHODIMP nsPrefBranch : : SetCharPref ( const char * aPrefName , const char * aValue )
2013-06-04 05:21:06 -07:00
{
nsresult rv = CheckSanityOfStringLength ( aPrefName , aValue ) ;
if ( NS_FAILED ( rv ) ) {
return rv ;
}
return SetCharPrefInternal ( aPrefName , aValue ) ;
}
nsresult nsPrefBranch : : SetCharPrefInternal ( const char * aPrefName , const char * aValue )
2007-03-22 10:30:00 -07:00
{
2013-12-03 15:18:09 -08:00
ENSURE_MAIN_PROCESS ( " Cannot SetCharPref from content process: " , aPrefName ) ;
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
NS_ENSURE_ARG ( aValue ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aPrefName ) ;
return PREF_SetCharPref ( pref , aValue , mIsDefault ) ;
2007-03-22 10:30:00 -07:00
}
2012-08-22 08:56:38 -07:00
NS_IMETHODIMP nsPrefBranch : : GetIntPref ( const char * aPrefName , int32_t * _retval )
2007-03-22 10:30:00 -07:00
{
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aPrefName ) ;
return PREF_GetIntPref ( pref , _retval , mIsDefault ) ;
2007-03-22 10:30:00 -07:00
}
2012-08-22 08:56:38 -07:00
NS_IMETHODIMP nsPrefBranch : : SetIntPref ( const char * aPrefName , int32_t aValue )
2007-03-22 10:30:00 -07:00
{
2013-12-03 15:18:09 -08:00
ENSURE_MAIN_PROCESS ( " Cannot SetIntPref from content process: " , aPrefName ) ;
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aPrefName ) ;
return PREF_SetIntPref ( pref , aValue , mIsDefault ) ;
2007-03-22 10:30:00 -07:00
}
2010-05-25 17:13:47 -07:00
NS_IMETHODIMP nsPrefBranch : : GetComplexValue ( const char * aPrefName , const nsIID & aType , void * * _retval )
2007-03-22 10:30:00 -07:00
{
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2007-03-22 10:30:00 -07:00
nsresult rv ;
nsXPIDLCString utf8String ;
// we have to do this one first because it's different than all the rest
if ( aType . Equals ( NS_GET_IID ( nsIPrefLocalizedString ) ) ) {
nsCOMPtr < nsIPrefLocalizedString > theString ( do_CreateInstance ( NS_PREFLOCALIZEDSTRING_CONTRACTID , & rv ) ) ;
2010-05-26 12:29:15 -07:00
if ( NS_FAILED ( rv ) ) return rv ;
2007-03-22 10:30:00 -07:00
2010-06-22 17:33:57 -07:00
const char * pref = getPrefName ( aPrefName ) ;
2011-09-28 23:19:26 -07:00
bool bNeedDefault = false ;
2007-03-22 10:30:00 -07:00
2010-05-26 12:29:15 -07:00
if ( mIsDefault ) {
2011-10-17 07:59:28 -07:00
bNeedDefault = true ;
2010-05-26 12:29:15 -07:00
} else {
// if there is no user (or locked) value
if ( ! PREF_HasUserPref ( pref ) & & ! PREF_PrefIsLocked ( pref ) ) {
2011-10-17 07:59:28 -07:00
bNeedDefault = true ;
2007-03-22 10:30:00 -07:00
}
2010-05-26 12:29:15 -07:00
}
2007-03-22 10:30:00 -07:00
2010-05-26 12:29:15 -07:00
// if we need to fetch the default value, do that instead, otherwise use the
// value we pulled in at the top of this function
if ( bNeedDefault ) {
nsXPIDLString utf16String ;
rv = GetDefaultFromPropertiesFile ( pref , getter_Copies ( utf16String ) ) ;
if ( NS_SUCCEEDED ( rv ) ) {
theString - > SetData ( utf16String . get ( ) ) ;
2007-03-22 10:30:00 -07:00
}
2010-05-26 12:29:15 -07:00
} else {
rv = GetCharPref ( aPrefName , getter_Copies ( utf8String ) ) ;
2007-03-22 10:30:00 -07:00
if ( NS_SUCCEEDED ( rv ) ) {
2010-05-26 12:29:15 -07:00
theString - > SetData ( NS_ConvertUTF8toUTF16 ( utf8String ) . get ( ) ) ;
2007-03-22 10:30:00 -07:00
}
}
2010-05-26 12:29:15 -07:00
if ( NS_SUCCEEDED ( rv ) ) {
2011-02-23 09:16:50 -08:00
theString . forget ( reinterpret_cast < nsIPrefLocalizedString * * > ( _retval ) ) ;
2010-05-26 12:29:15 -07:00
}
2007-03-22 10:30:00 -07:00
return rv ;
}
// if we can't get the pref, there's no point in being here
rv = GetCharPref ( aPrefName , getter_Copies ( utf8String ) ) ;
if ( NS_FAILED ( rv ) ) {
return rv ;
}
2012-06-05 19:08:30 -07:00
// also check nsILocalFile, for backwards compatibility
if ( aType . Equals ( NS_GET_IID ( nsIFile ) ) | | aType . Equals ( NS_GET_IID ( nsILocalFile ) ) ) {
2010-07-19 11:33:33 -07:00
if ( GetContentChild ( ) ) {
2012-06-05 19:08:30 -07:00
NS_ERROR ( " cannot get nsIFile pref from content process " ) ;
2010-05-26 12:29:15 -07:00
return NS_ERROR_NOT_AVAILABLE ;
}
2012-06-05 19:08:30 -07:00
nsCOMPtr < nsIFile > file ( do_CreateInstance ( NS_LOCAL_FILE_CONTRACTID , & rv ) ) ;
2007-03-22 10:30:00 -07:00
if ( NS_SUCCEEDED ( rv ) ) {
rv = file - > SetPersistentDescriptor ( utf8String ) ;
if ( NS_SUCCEEDED ( rv ) ) {
2012-06-05 19:08:30 -07:00
file . forget ( reinterpret_cast < nsIFile * * > ( _retval ) ) ;
2007-03-22 10:30:00 -07:00
return NS_OK ;
}
}
return rv ;
}
if ( aType . Equals ( NS_GET_IID ( nsIRelativeFilePref ) ) ) {
2010-07-19 11:33:33 -07:00
if ( GetContentChild ( ) ) {
2010-05-26 12:29:15 -07:00
NS_ERROR ( " cannot get nsIRelativeFilePref from content process " ) ;
return NS_ERROR_NOT_AVAILABLE ;
}
2007-03-22 10:30:00 -07:00
nsACString : : const_iterator keyBegin , strEnd ;
utf8String . BeginReading ( keyBegin ) ;
utf8String . EndReading ( strEnd ) ;
// The pref has the format: [fromKey]a/b/c
if ( * keyBegin + + ! = ' [ ' )
2010-05-25 17:13:47 -07:00
return NS_ERROR_FAILURE ;
2007-03-22 10:30:00 -07:00
nsACString : : const_iterator keyEnd ( keyBegin ) ;
if ( ! FindCharInReadable ( ' ] ' , keyEnd , strEnd ) )
2010-05-25 17:13:47 -07:00
return NS_ERROR_FAILURE ;
2012-09-01 19:35:17 -07:00
nsAutoCString key ( Substring ( keyBegin , keyEnd ) ) ;
2007-03-22 10:30:00 -07:00
2012-06-05 19:08:30 -07:00
nsCOMPtr < nsIFile > fromFile ;
2007-03-22 10:30:00 -07:00
nsCOMPtr < nsIProperties > directoryService ( do_GetService ( NS_DIRECTORY_SERVICE_CONTRACTID , & rv ) ) ;
if ( NS_FAILED ( rv ) )
return rv ;
2012-06-05 19:08:30 -07:00
rv = directoryService - > Get ( key . get ( ) , NS_GET_IID ( nsIFile ) , getter_AddRefs ( fromFile ) ) ;
2007-03-22 10:30:00 -07:00
if ( NS_FAILED ( rv ) )
return rv ;
2012-06-05 19:08:30 -07:00
nsCOMPtr < nsIFile > theFile ;
2011-10-17 07:59:28 -07:00
rv = NS_NewNativeLocalFile ( EmptyCString ( ) , true , getter_AddRefs ( theFile ) ) ;
2007-03-22 10:30:00 -07:00
if ( NS_FAILED ( rv ) )
return rv ;
rv = theFile - > SetRelativeDescriptor ( fromFile , Substring ( + + keyEnd , strEnd ) ) ;
if ( NS_FAILED ( rv ) )
return rv ;
nsCOMPtr < nsIRelativeFilePref > relativePref ;
rv = NS_NewRelativeFilePref ( theFile , key , getter_AddRefs ( relativePref ) ) ;
if ( NS_FAILED ( rv ) )
return rv ;
2010-05-26 12:29:15 -07:00
relativePref . forget ( reinterpret_cast < nsIRelativeFilePref * * > ( _retval ) ) ;
2007-03-22 10:30:00 -07:00
return NS_OK ;
}
if ( aType . Equals ( NS_GET_IID ( nsISupportsString ) ) ) {
nsCOMPtr < nsISupportsString > theString ( do_CreateInstance ( NS_SUPPORTS_STRING_CONTRACTID , & rv ) ) ;
if ( NS_SUCCEEDED ( rv ) ) {
2013-03-08 09:27:58 -08:00
// Debugging to see why we end up with very long strings here with
// some addons, see bug 836263.
nsAutoString wdata ;
if ( ! AppendUTF8toUTF16 ( utf8String , wdata , mozilla : : fallible_t ( ) ) ) {
# ifdef MOZ_CRASHREPORTER
nsCOMPtr < nsICrashReporter > cr =
do_GetService ( " @mozilla.org/toolkit/crash-reporter;1 " ) ;
if ( cr ) {
cr - > AnnotateCrashReport ( NS_LITERAL_CSTRING ( " bug836263-size " ) ,
nsPrintfCString ( " %x " , utf8String . Length ( ) ) ) ;
cr - > RegisterAppMemory ( uint64_t ( utf8String . BeginReading ( ) ) ,
std : : min ( 0x1000U , utf8String . Length ( ) ) ) ;
}
# endif
NS_RUNTIMEABORT ( " bug836263 " ) ;
}
theString - > SetData ( wdata ) ;
2010-05-26 12:29:15 -07:00
theString . forget ( reinterpret_cast < nsISupportsString * * > ( _retval ) ) ;
2007-03-22 10:30:00 -07:00
}
return rv ;
}
NS_WARNING ( " nsPrefBranch::GetComplexValue - Unsupported interface type " ) ;
return NS_NOINTERFACE ;
}
2013-06-04 05:21:06 -07:00
nsresult nsPrefBranch : : CheckSanityOfStringLength ( const char * aPrefName , const char * aValue ) {
if ( ! aValue ) {
return NS_OK ;
}
return CheckSanityOfStringLength ( aPrefName , strlen ( aValue ) ) ;
}
nsresult nsPrefBranch : : CheckSanityOfStringLength ( const char * aPrefName , const nsAString & aValue ) {
return CheckSanityOfStringLength ( aPrefName , aValue . Length ( ) ) ;
}
nsresult nsPrefBranch : : CheckSanityOfStringLength ( const char * aPrefName , const uint32_t aLength ) {
if ( aLength > MAX_PREF_LENGTH ) {
2014-01-21 12:51:05 -08:00
return NS_ERROR_ILLEGAL_VALUE ;
2013-06-04 05:21:06 -07:00
}
if ( aLength < = MAX_ADVISABLE_PREF_LENGTH ) {
return NS_OK ;
}
nsresult rv ;
nsCOMPtr < nsIConsoleService > console = do_GetService ( " @mozilla.org/consoleservice;1 " , & rv ) ;
if ( NS_FAILED ( rv ) ) {
return rv ;
}
nsAutoCString message ( nsPrintfCString ( " Warning: attempting to write %d bytes to preference %s. This is bad for general performance and memory usage. Such an amount of data should rather be written to an external file. " ,
aLength ,
aPrefName ) ) ;
rv = console - > LogStringMessage ( NS_ConvertUTF8toUTF16 ( message ) . get ( ) ) ;
if ( NS_FAILED ( rv ) ) {
return rv ;
}
return NS_OK ;
}
2007-03-22 10:30:00 -07:00
NS_IMETHODIMP nsPrefBranch : : SetComplexValue ( const char * aPrefName , const nsIID & aType , nsISupports * aValue )
{
2013-12-03 15:18:09 -08:00
ENSURE_MAIN_PROCESS ( " Cannot SetComplexValue from content process: " , aPrefName ) ;
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2007-03-22 10:30:00 -07:00
nsresult rv = NS_NOINTERFACE ;
2012-06-05 19:08:30 -07:00
// also check nsILocalFile, for backwards compatibility
if ( aType . Equals ( NS_GET_IID ( nsIFile ) ) | | aType . Equals ( NS_GET_IID ( nsILocalFile ) ) ) {
nsCOMPtr < nsIFile > file = do_QueryInterface ( aValue ) ;
2007-03-22 10:30:00 -07:00
if ( ! file )
return NS_NOINTERFACE ;
2012-09-01 19:35:17 -07:00
nsAutoCString descriptorString ;
2007-03-22 10:30:00 -07:00
rv = file - > GetPersistentDescriptor ( descriptorString ) ;
if ( NS_SUCCEEDED ( rv ) ) {
2013-06-04 05:21:06 -07:00
rv = SetCharPrefInternal ( aPrefName , descriptorString . get ( ) ) ;
2007-03-22 10:30:00 -07:00
}
return rv ;
}
if ( aType . Equals ( NS_GET_IID ( nsIRelativeFilePref ) ) ) {
nsCOMPtr < nsIRelativeFilePref > relFilePref = do_QueryInterface ( aValue ) ;
if ( ! relFilePref )
return NS_NOINTERFACE ;
2013-06-04 05:21:06 -07:00
2012-06-05 19:08:30 -07:00
nsCOMPtr < nsIFile > file ;
2007-03-22 10:30:00 -07:00
relFilePref - > GetFile ( getter_AddRefs ( file ) ) ;
if ( ! file )
return NS_NOINTERFACE ;
2012-09-01 19:35:17 -07:00
nsAutoCString relativeToKey ;
2007-03-22 10:30:00 -07:00
( void ) relFilePref - > GetRelativeToKey ( relativeToKey ) ;
2012-06-05 19:08:30 -07:00
nsCOMPtr < nsIFile > relativeToFile ;
2007-03-22 10:30:00 -07:00
nsCOMPtr < nsIProperties > directoryService ( do_GetService ( NS_DIRECTORY_SERVICE_CONTRACTID , & rv ) ) ;
if ( NS_FAILED ( rv ) )
return rv ;
2012-06-05 19:08:30 -07:00
rv = directoryService - > Get ( relativeToKey . get ( ) , NS_GET_IID ( nsIFile ) , getter_AddRefs ( relativeToFile ) ) ;
2007-03-22 10:30:00 -07:00
if ( NS_FAILED ( rv ) )
return rv ;
2012-09-01 19:35:17 -07:00
nsAutoCString relDescriptor ;
2007-03-22 10:30:00 -07:00
rv = file - > GetRelativeDescriptor ( relativeToFile , relDescriptor ) ;
if ( NS_FAILED ( rv ) )
return rv ;
2013-06-04 05:21:06 -07:00
2012-09-01 19:35:17 -07:00
nsAutoCString descriptorString ;
2007-03-22 10:30:00 -07:00
descriptorString . Append ( ' [ ' ) ;
descriptorString . Append ( relativeToKey ) ;
descriptorString . Append ( ' ] ' ) ;
descriptorString . Append ( relDescriptor ) ;
2013-06-04 05:21:06 -07:00
return SetCharPrefInternal ( aPrefName , descriptorString . get ( ) ) ;
2007-03-22 10:30:00 -07:00
}
if ( aType . Equals ( NS_GET_IID ( nsISupportsString ) ) ) {
nsCOMPtr < nsISupportsString > theString = do_QueryInterface ( aValue ) ;
if ( theString ) {
2013-05-01 13:21:23 -07:00
nsString wideString ;
2007-03-22 10:30:00 -07:00
rv = theString - > GetData ( wideString ) ;
if ( NS_SUCCEEDED ( rv ) ) {
2013-06-04 05:21:06 -07:00
// Check sanity of string length before any lengthy conversion
rv = CheckSanityOfStringLength ( aPrefName , wideString ) ;
if ( NS_FAILED ( rv ) ) {
return rv ;
2013-05-01 13:21:23 -07:00
}
2013-06-04 05:21:06 -07:00
rv = SetCharPrefInternal ( aPrefName , NS_ConvertUTF16toUTF8 ( wideString ) . get ( ) ) ;
2007-03-22 10:30:00 -07:00
}
}
return rv ;
}
if ( aType . Equals ( NS_GET_IID ( nsIPrefLocalizedString ) ) ) {
nsCOMPtr < nsIPrefLocalizedString > theString = do_QueryInterface ( aValue ) ;
if ( theString ) {
nsXPIDLString wideString ;
rv = theString - > GetData ( getter_Copies ( wideString ) ) ;
if ( NS_SUCCEEDED ( rv ) ) {
2013-06-04 05:21:06 -07:00
// Check sanity of string length before any lengthy conversion
rv = CheckSanityOfStringLength ( aPrefName , wideString ) ;
if ( NS_FAILED ( rv ) ) {
return rv ;
2013-05-01 13:21:23 -07:00
}
2013-06-04 05:21:06 -07:00
rv = SetCharPrefInternal ( aPrefName , NS_ConvertUTF16toUTF8 ( wideString ) . get ( ) ) ;
2007-03-22 10:30:00 -07:00
}
}
return rv ;
}
NS_WARNING ( " nsPrefBranch::SetComplexValue - Unsupported interface type " ) ;
return NS_NOINTERFACE ;
}
NS_IMETHODIMP nsPrefBranch : : ClearUserPref ( const char * aPrefName )
{
2013-12-03 15:18:09 -08:00
ENSURE_MAIN_PROCESS ( " Cannot ClearUserPref from content process: " , aPrefName ) ;
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aPrefName ) ;
return PREF_ClearUserPref ( pref ) ;
2007-03-22 10:30:00 -07:00
}
2011-09-28 23:19:26 -07:00
NS_IMETHODIMP nsPrefBranch : : PrefHasUserValue ( const char * aPrefName , bool * _retval )
2007-03-22 10:30:00 -07:00
{
NS_ENSURE_ARG_POINTER ( _retval ) ;
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aPrefName ) ;
* _retval = PREF_HasUserPref ( pref ) ;
return NS_OK ;
2007-03-22 10:30:00 -07:00
}
NS_IMETHODIMP nsPrefBranch : : LockPref ( const char * aPrefName )
{
2013-12-03 15:18:09 -08:00
ENSURE_MAIN_PROCESS ( " Cannot LockPref from content process: " , aPrefName ) ;
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aPrefName ) ;
2011-10-17 07:59:28 -07:00
return PREF_LockPref ( pref , true ) ;
2007-03-22 10:30:00 -07:00
}
2011-09-28 23:19:26 -07:00
NS_IMETHODIMP nsPrefBranch : : PrefIsLocked ( const char * aPrefName , bool * _retval )
2007-03-22 10:30:00 -07:00
{
2013-12-03 15:18:09 -08:00
ENSURE_MAIN_PROCESS ( " Cannot check PrefIsLocked from content process: " , aPrefName ) ;
2010-09-27 14:23:35 -07:00
NS_ENSURE_ARG_POINTER ( _retval ) ;
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aPrefName ) ;
* _retval = PREF_PrefIsLocked ( pref ) ;
return NS_OK ;
2007-03-22 10:30:00 -07:00
}
NS_IMETHODIMP nsPrefBranch : : UnlockPref ( const char * aPrefName )
{
2013-12-03 15:18:09 -08:00
ENSURE_MAIN_PROCESS ( " Cannot UnlockPref from content process: " , aPrefName ) ;
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aPrefName ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aPrefName ) ;
2011-10-17 07:59:28 -07:00
return PREF_LockPref ( pref , false ) ;
2007-03-22 10:30:00 -07:00
}
/* void resetBranch (in string startingAt); */
NS_IMETHODIMP nsPrefBranch : : ResetBranch ( const char * aStartingAt )
{
return NS_ERROR_NOT_IMPLEMENTED ;
}
NS_IMETHODIMP nsPrefBranch : : DeleteBranch ( const char * aStartingAt )
{
2013-12-03 15:18:09 -08:00
ENSURE_MAIN_PROCESS ( " Cannot DeleteBranch from content process: " , aStartingAt ) ;
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aStartingAt ) ;
2010-06-08 16:43:54 -07:00
const char * pref = getPrefName ( aStartingAt ) ;
return PREF_DeleteBranch ( pref ) ;
2007-03-22 10:30:00 -07:00
}
2012-08-22 08:56:38 -07:00
NS_IMETHODIMP nsPrefBranch : : GetChildList ( const char * aStartingAt , uint32_t * aCount , char * * * aChildArray )
2007-03-22 10:30:00 -07:00
{
2010-05-25 17:13:47 -07:00
char * * outArray ;
2012-08-22 08:56:38 -07:00
int32_t numPrefs ;
int32_t dwIndex ;
2007-03-22 10:30:00 -07:00
EnumerateData ed ;
2010-05-28 11:09:15 -07:00
nsAutoTArray < nsCString , 32 > prefArray ;
2007-03-22 10:30:00 -07:00
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aStartingAt ) ;
2007-03-22 10:30:00 -07:00
NS_ENSURE_ARG_POINTER ( aCount ) ;
NS_ENSURE_ARG_POINTER ( aChildArray ) ;
2012-07-30 07:20:58 -07:00
* aChildArray = nullptr ;
2010-05-28 11:09:15 -07:00
* aCount = 0 ;
2010-09-27 14:23:35 -07:00
if ( ! gHashTable . ops )
return NS_ERROR_NOT_INITIALIZED ;
2010-05-28 11:09:15 -07:00
2010-09-27 14:23:35 -07:00
// this will contain a list of all the pref name strings
// allocate on the stack for speed
ed . parent = getPrefName ( aStartingAt ) ;
ed . pref_list = & prefArray ;
PL_DHashTableEnumerate ( & gHashTable , pref_enumChild , & ed ) ;
2007-03-22 10:30:00 -07:00
// now that we've built up the list, run the callback on
// all the matching elements
2010-05-28 11:09:15 -07:00
numPrefs = prefArray . Length ( ) ;
2007-03-22 10:30:00 -07:00
if ( numPrefs ) {
outArray = ( char * * ) nsMemory : : Alloc ( numPrefs * sizeof ( char * ) ) ;
if ( ! outArray )
return NS_ERROR_OUT_OF_MEMORY ;
for ( dwIndex = 0 ; dwIndex < numPrefs ; + + dwIndex ) {
// we need to lop off mPrefRoot in case the user is planning to pass this
// back to us because if they do we are going to add mPrefRoot again.
2010-05-28 11:09:15 -07:00
const nsCString & element = prefArray [ dwIndex ] ;
outArray [ dwIndex ] = ( char * ) nsMemory : : Clone (
element . get ( ) + mPrefRootLength , element . Length ( ) - mPrefRootLength + 1 ) ;
2007-03-22 10:30:00 -07:00
if ( ! outArray [ dwIndex ] ) {
// we ran out of memory... this is annoying
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY ( dwIndex , outArray ) ;
return NS_ERROR_OUT_OF_MEMORY ;
}
}
* aChildArray = outArray ;
2010-05-28 11:09:15 -07:00
}
2007-03-22 10:30:00 -07:00
* aCount = numPrefs ;
return NS_OK ;
}
2011-09-28 23:19:26 -07:00
NS_IMETHODIMP nsPrefBranch : : AddObserver ( const char * aDomain , nsIObserver * aObserver , bool aHoldWeak )
2007-03-22 10:30:00 -07:00
{
2010-07-16 14:10:01 -07:00
PrefCallback * pCallback ;
2007-03-22 10:30:00 -07:00
const char * pref ;
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aDomain ) ;
NS_ENSURE_ARG ( aObserver ) ;
2007-03-22 10:30:00 -07:00
// hold a weak reference to the observer if so requested
if ( aHoldWeak ) {
nsCOMPtr < nsISupportsWeakReference > weakRefFactory = do_QueryInterface ( aObserver ) ;
if ( ! weakRefFactory ) {
// the caller didn't give us a object that supports weak reference... tell them
return NS_ERROR_INVALID_ARG ;
}
2010-07-16 14:10:01 -07:00
// Construct a PrefCallback with a weak reference to the observer.
pCallback = new PrefCallback ( aDomain , weakRefFactory , this ) ;
2007-03-22 10:30:00 -07:00
} else {
2010-07-16 14:10:01 -07:00
// Construct a PrefCallback with a strong reference to the observer.
pCallback = new PrefCallback ( aDomain , aObserver , this ) ;
}
if ( mObservers . Get ( pCallback ) ) {
NS_WARNING ( " Ignoring duplicate observer. " ) ;
delete pCallback ;
return NS_OK ;
2007-03-22 10:30:00 -07:00
}
2012-05-18 10:30:49 -07:00
mObservers . Put ( pCallback , pCallback ) ;
2007-03-22 10:30:00 -07:00
// We must pass a fully qualified preference name to the callback
2012-07-30 07:20:58 -07:00
// aDomain == nullptr is the only possible failure, and we trapped it with
2010-10-07 14:00:17 -07:00
// NS_ENSURE_ARG above.
2010-07-16 14:10:01 -07:00
pref = getPrefName ( aDomain ) ;
2007-03-22 10:30:00 -07:00
PREF_RegisterCallback ( pref , NotifyObserver , pCallback ) ;
return NS_OK ;
}
NS_IMETHODIMP nsPrefBranch : : RemoveObserver ( const char * aDomain , nsIObserver * aObserver )
{
2010-10-07 14:00:17 -07:00
NS_ENSURE_ARG ( aDomain ) ;
NS_ENSURE_ARG ( aObserver ) ;
2007-03-22 10:30:00 -07:00
2010-07-16 14:10:01 -07:00
nsresult rv = NS_OK ;
// If we're in the middle of a call to freeObserverList, don't process this
// RemoveObserver call -- the observer in question will be removed soon, if
// it hasn't been already.
//
// It's important that we don't touch mObservers in any way -- even a Get()
// which retuns null might cause the hashtable to resize itself, which will
// break the Enumerator in freeObserverList.
if ( mFreeingObserverList )
2007-03-22 10:30:00 -07:00
return NS_OK ;
2010-07-16 14:10:01 -07:00
// Remove the relevant PrefCallback from mObservers and get an owning
// pointer to it. Unregister the callback first, and then let the owning
// pointer go out of scope and destroy the callback.
PrefCallback key ( aDomain , aObserver , this ) ;
nsAutoPtr < PrefCallback > pCallback ;
mObservers . RemoveAndForget ( & key , pCallback ) ;
if ( pCallback ) {
2012-07-30 07:20:58 -07:00
// aDomain == nullptr is the only possible failure, trapped above
2010-07-16 14:10:01 -07:00
const char * pref = getPrefName ( aDomain ) ;
rv = PREF_UnregisterCallback ( pref , NotifyObserver , pCallback ) ;
}
return rv ;
2007-03-22 10:30:00 -07:00
}
2014-01-04 07:02:17 -08:00
NS_IMETHODIMP nsPrefBranch : : Observe ( nsISupports * aSubject , const char * aTopic , const char16_t * someData )
2007-03-22 10:30:00 -07:00
{
// watch for xpcom shutdown and free our observers to eliminate any cyclic references
if ( ! nsCRT : : strcmp ( aTopic , NS_XPCOM_SHUTDOWN_OBSERVER_ID ) ) {
freeObserverList ( ) ;
}
return NS_OK ;
}
2010-07-16 14:10:01 -07:00
/* static */
2013-12-10 15:10:01 -08:00
void nsPrefBranch : : NotifyObserver ( const char * newpref , void * data )
2007-03-22 10:30:00 -07:00
{
2010-07-16 14:10:01 -07:00
PrefCallback * pCallback = ( PrefCallback * ) data ;
nsCOMPtr < nsIObserver > observer = pCallback - > GetObserver ( ) ;
if ( ! observer ) {
// The observer has expired. Let's remove this callback.
pCallback - > GetPrefBranch ( ) - > RemoveExpiredCallback ( pCallback ) ;
2013-12-10 15:10:01 -08:00
return ;
2010-07-16 14:10:01 -07:00
}
2007-03-22 10:30:00 -07:00
// remove any root this string may contain so as to not confuse the observer
// by passing them something other than what they passed us as a topic
2012-08-22 08:56:38 -07:00
uint32_t len = pCallback - > GetPrefBranch ( ) - > GetRootLength ( ) ;
2012-09-01 19:35:17 -07:00
nsAutoCString suffix ( newpref + len ) ;
2007-03-22 10:30:00 -07:00
2010-07-16 14:10:01 -07:00
observer - > Observe ( static_cast < nsIPrefBranch * > ( pCallback - > GetPrefBranch ( ) ) ,
2007-03-22 10:30:00 -07:00
NS_PREFBRANCH_PREFCHANGE_TOPIC_ID ,
NS_ConvertASCIItoUTF16 ( suffix ) . get ( ) ) ;
}
2010-07-16 14:10:01 -07:00
PLDHashOperator
FreeObserverFunc ( PrefCallback * aKey ,
nsAutoPtr < PrefCallback > & aCallback ,
void * aArgs )
2010-07-14 17:39:22 -07:00
{
2010-07-16 14:10:01 -07:00
// Calling NS_RELEASE below might trigger a call to
// nsPrefBranch::RemoveObserver, since some classes remove themselves from
// the pref branch on destruction. We don't need to worry about this causing
// double-frees, however, because freeObserverList sets mFreeingObserverList
// to true, which prevents RemoveObserver calls from doing anything.
2010-08-18 14:38:05 -07:00
2010-07-16 14:10:01 -07:00
nsPrefBranch * prefBranch = aCallback - > GetPrefBranch ( ) ;
const char * pref = prefBranch - > getPrefName ( aCallback - > GetDomain ( ) . get ( ) ) ;
PREF_UnregisterCallback ( pref , nsPrefBranch : : NotifyObserver , aCallback ) ;
return PL_DHASH_REMOVE ;
2010-07-16 14:10:01 -07:00
}
2010-07-14 17:39:22 -07:00
2010-07-16 14:10:01 -07:00
void nsPrefBranch : : freeObserverList ( void )
2010-07-16 14:10:01 -07:00
{
2010-07-16 14:10:01 -07:00
// We need to prevent anyone from modifying mObservers while we're
// enumerating over it. In particular, some clients will call
// RemoveObserver() when they're destructed; we need to keep those calls from
// touching mObservers.
2011-10-17 07:59:28 -07:00
mFreeingObserverList = true ;
2012-07-30 07:20:58 -07:00
mObservers . Enumerate ( & FreeObserverFunc , nullptr ) ;
2011-10-17 07:59:28 -07:00
mFreeingObserverList = false ;
2010-07-16 14:10:01 -07:00
}
2010-08-18 14:38:05 -07:00
2010-07-16 14:10:01 -07:00
void
nsPrefBranch : : RemoveExpiredCallback ( PrefCallback * aCallback )
{
NS_PRECONDITION ( aCallback - > IsExpired ( ) , " Callback should be expired. " ) ;
mObservers . Remove ( aCallback ) ;
2010-08-18 14:38:05 -07:00
}
2010-07-16 14:10:01 -07:00
2014-01-04 07:02:17 -08:00
nsresult nsPrefBranch : : GetDefaultFromPropertiesFile ( const char * aPrefName , char16_t * * return_buf )
2007-03-22 10:30:00 -07:00
{
nsresult rv ;
// the default value contains a URL to a .properties file
nsXPIDLCString propertyFileURL ;
2011-10-17 07:59:28 -07:00
rv = PREF_CopyCharPref ( aPrefName , getter_Copies ( propertyFileURL ) , true ) ;
2007-03-22 10:30:00 -07:00
if ( NS_FAILED ( rv ) )
return rv ;
2010-05-14 02:24:41 -07:00
2007-03-22 10:30:00 -07:00
nsCOMPtr < nsIStringBundleService > bundleService =
2010-05-14 02:24:41 -07:00
mozilla : : services : : GetStringBundleService ( ) ;
if ( ! bundleService )
return NS_ERROR_FAILURE ;
2007-03-22 10:30:00 -07:00
nsCOMPtr < nsIStringBundle > bundle ;
rv = bundleService - > CreateBundle ( propertyFileURL ,
getter_AddRefs ( bundle ) ) ;
if ( NS_FAILED ( rv ) )
return rv ;
// string names are in unicode
nsAutoString stringId ;
stringId . AssignASCII ( aPrefName ) ;
return bundle - > GetStringFromName ( stringId . get ( ) , return_buf ) ;
}
const char * nsPrefBranch : : getPrefName ( const char * aPrefName )
{
2010-10-07 14:00:17 -07:00
NS_ASSERTION ( aPrefName , " null pref name! " ) ;
2007-03-22 10:30:00 -07:00
// for speed, avoid strcpy if we can:
if ( mPrefRoot . IsEmpty ( ) )
return aPrefName ;
// isn't there a better way to do this? this is really kind of gross.
mPrefRoot . Truncate ( mPrefRootLength ) ;
2010-10-07 14:00:17 -07:00
mPrefRoot . Append ( aPrefName ) ;
2007-03-22 10:30:00 -07:00
return mPrefRoot . get ( ) ;
}
2008-10-10 08:04:34 -07:00
static PLDHashOperator
2007-03-22 10:30:00 -07:00
pref_enumChild ( PLDHashTable * table , PLDHashEntryHdr * heh ,
2012-08-22 08:56:38 -07:00
uint32_t i , void * arg )
2007-03-22 10:30:00 -07:00
{
2007-07-08 00:08:04 -07:00
PrefHashEntry * he = static_cast < PrefHashEntry * > ( heh ) ;
EnumerateData * d = reinterpret_cast < EnumerateData * > ( arg ) ;
2010-05-28 11:09:15 -07:00
if ( strncmp ( he - > key , d - > parent , strlen ( d - > parent ) ) = = 0 ) {
d - > pref_list - > AppendElement ( he - > key ) ;
2007-03-22 10:30:00 -07:00
}
return PL_DHASH_NEXT ;
}
//----------------------------------------------------------------------------
// nsPrefLocalizedString
//----------------------------------------------------------------------------
nsPrefLocalizedString : : nsPrefLocalizedString ( )
{
}
nsPrefLocalizedString : : ~ nsPrefLocalizedString ( )
{
}
/*
* nsISupports Implementation
*/
2013-07-18 19:23:44 -07:00
NS_IMPL_ADDREF ( nsPrefLocalizedString )
NS_IMPL_RELEASE ( nsPrefLocalizedString )
2007-03-22 10:30:00 -07:00
NS_INTERFACE_MAP_BEGIN ( nsPrefLocalizedString )
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS ( nsISupports , nsIPrefLocalizedString )
NS_INTERFACE_MAP_ENTRY ( nsIPrefLocalizedString )
NS_INTERFACE_MAP_ENTRY ( nsISupportsString )
NS_INTERFACE_MAP_END
nsresult nsPrefLocalizedString : : Init ( )
{
nsresult rv ;
mUnicodeString = do_CreateInstance ( NS_SUPPORTS_STRING_CONTRACTID , & rv ) ;
return rv ;
}
NS_IMETHODIMP
2014-01-04 07:02:17 -08:00
nsPrefLocalizedString : : GetData ( char16_t * * _retval )
2007-03-22 10:30:00 -07:00
{
nsAutoString data ;
nsresult rv = GetData ( data ) ;
if ( NS_FAILED ( rv ) )
return rv ;
* _retval = ToNewUnicode ( data ) ;
if ( ! * _retval )
return NS_ERROR_OUT_OF_MEMORY ;
return NS_OK ;
}
NS_IMETHODIMP
2014-01-04 07:02:17 -08:00
nsPrefLocalizedString : : SetData ( const char16_t * aData )
2007-03-22 10:30:00 -07:00
{
if ( ! aData )
return SetData ( EmptyString ( ) ) ;
return SetData ( nsDependentString ( aData ) ) ;
}
NS_IMETHODIMP
2012-08-22 08:56:38 -07:00
nsPrefLocalizedString : : SetDataWithLength ( uint32_t aLength ,
2014-01-04 07:02:17 -08:00
const char16_t * aData )
2007-03-22 10:30:00 -07:00
{
if ( ! aData )
return SetData ( EmptyString ( ) ) ;
2011-12-09 00:35:41 -08:00
return SetData ( Substring ( aData , aLength ) ) ;
2007-03-22 10:30:00 -07:00
}
//----------------------------------------------------------------------------
// nsRelativeFilePref
//----------------------------------------------------------------------------
2014-04-27 00:06:00 -07:00
NS_IMPL_ISUPPORTS ( nsRelativeFilePref , nsIRelativeFilePref )
2007-03-22 10:30:00 -07:00
nsRelativeFilePref : : nsRelativeFilePref ( )
{
}
nsRelativeFilePref : : ~ nsRelativeFilePref ( )
{
}
2012-06-05 19:08:30 -07:00
NS_IMETHODIMP nsRelativeFilePref : : GetFile ( nsIFile * * aFile )
2007-03-22 10:30:00 -07:00
{
2010-05-25 17:13:47 -07:00
NS_ENSURE_ARG_POINTER ( aFile ) ;
* aFile = mFile ;
NS_IF_ADDREF ( * aFile ) ;
return NS_OK ;
2007-03-22 10:30:00 -07:00
}
2012-06-05 19:08:30 -07:00
NS_IMETHODIMP nsRelativeFilePref : : SetFile ( nsIFile * aFile )
2007-03-22 10:30:00 -07:00
{
2010-05-25 17:13:47 -07:00
mFile = aFile ;
return NS_OK ;
2007-03-22 10:30:00 -07:00
}
NS_IMETHODIMP nsRelativeFilePref : : GetRelativeToKey ( nsACString & aRelativeToKey )
{
2010-05-25 17:13:47 -07:00
aRelativeToKey . Assign ( mRelativeToKey ) ;
return NS_OK ;
2007-03-22 10:30:00 -07:00
}
NS_IMETHODIMP nsRelativeFilePref : : SetRelativeToKey ( const nsACString & aRelativeToKey )
{
2010-05-25 17:13:47 -07:00
mRelativeToKey . Assign ( aRelativeToKey ) ;
return NS_OK ;
2007-03-22 10:30:00 -07:00
}
2013-12-03 15:18:09 -08:00
# undef ENSURE_MAIN_PROCESS