зеркало из https://github.com/mozilla/gecko-dev.git
Bug 698217 DeCOMtaminate nsIPrefServiceInternal r=roc
This commit is contained in:
Родитель
d9fb132443
Коммит
c160626ea3
|
@ -60,6 +60,7 @@
|
|||
#include "mozilla/ipc/XPCShellEnvironment.h"
|
||||
#include "mozilla/jsipc/PContextWrapperChild.h"
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#if defined(MOZ_SYDNEYAUDIO)
|
||||
#include "nsAudioStream.h"
|
||||
|
@ -68,7 +69,6 @@
|
|||
#include "nsIObserverService.h"
|
||||
#include "nsTObserverArray.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
@ -638,24 +638,14 @@ ContentChild::AddRemoteAlertObserver(const nsString& aData,
|
|||
bool
|
||||
ContentChild::RecvPreferenceUpdate(const PrefTuple& aPref)
|
||||
{
|
||||
nsCOMPtr<nsIPrefServiceInternal> prefs = do_GetService("@mozilla.org/preferences-service;1");
|
||||
if (!prefs)
|
||||
return false;
|
||||
|
||||
prefs->SetPreference(&aPref);
|
||||
|
||||
Preferences::SetPreference(&aPref);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::RecvClearUserPreference(const nsCString& aPrefName)
|
||||
{
|
||||
nsCOMPtr<nsIPrefServiceInternal> prefs = do_GetService("@mozilla.org/preferences-service;1");
|
||||
if (!prefs)
|
||||
return false;
|
||||
|
||||
prefs->ClearContentPref(aPrefName);
|
||||
|
||||
Preferences::ClearContentPref(aPrefName.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include "nsIDOMWindow.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefBranch2.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -461,7 +460,7 @@ bool
|
|||
ContentParent::RecvReadPrefsArray(InfallibleTArray<PrefTuple> *prefs)
|
||||
{
|
||||
EnsurePrefService();
|
||||
mPrefService->MirrorPreferences(prefs);
|
||||
Preferences::MirrorPreferences(prefs);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -707,33 +706,9 @@ ContentParent::Observe(nsISupports* aSubject,
|
|||
// We know prefs are ASCII here.
|
||||
NS_LossyConvertUTF16toASCII strData(aData);
|
||||
|
||||
nsCOMPtr<nsIPrefServiceInternal> prefService =
|
||||
do_GetService("@mozilla.org/preferences-service;1");
|
||||
|
||||
bool prefNeedUpdate;
|
||||
prefService->PrefHasUserValue(strData, &prefNeedUpdate);
|
||||
|
||||
// If the pref does not have a user value, check if it exist on the
|
||||
// default branch or not
|
||||
if (!prefNeedUpdate) {
|
||||
nsCOMPtr<nsIPrefBranch> defaultBranch;
|
||||
nsCOMPtr<nsIPrefService> prefsService = do_QueryInterface(prefService);
|
||||
prefsService->GetDefaultBranch(nsnull, getter_AddRefs(defaultBranch));
|
||||
|
||||
PRInt32 prefType = nsIPrefBranch::PREF_INVALID;
|
||||
defaultBranch->GetPrefType(strData.get(), &prefType);
|
||||
prefNeedUpdate = (prefType != nsIPrefBranch::PREF_INVALID);
|
||||
}
|
||||
|
||||
PrefTuple pref;
|
||||
bool prefNeedUpdate = Preferences::MirrorPreference(strData.get(), &pref);
|
||||
if (prefNeedUpdate) {
|
||||
// Pref was created, or previously existed and its value
|
||||
// changed.
|
||||
PrefTuple pref;
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
prefService->MirrorPreference(strData, &pref);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Pref has value but can't mirror?");
|
||||
if (!SendPreferenceUpdate(pref)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ private:
|
|||
nsCOMArray<nsIMemoryReporter> mMemoryReporters;
|
||||
|
||||
bool mIsAlive;
|
||||
nsCOMPtr<nsIPrefServiceInternal> mPrefService;
|
||||
nsCOMPtr<nsIPrefService> mPrefService;
|
||||
|
||||
bool mSendPermissionUpdates;
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ typedef int (*PR_CALLBACK PrefChangedFunc)(const char *, void *);
|
|||
namespace mozilla {
|
||||
|
||||
class Preferences : public nsIPrefService,
|
||||
public nsIPrefServiceInternal,
|
||||
public nsIObserver,
|
||||
public nsIPrefBranchInternal,
|
||||
public nsSupportsWeakReference
|
||||
|
@ -73,7 +72,6 @@ class Preferences : public nsIPrefService,
|
|||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPREFSERVICE
|
||||
NS_DECL_NSIPREFSERVICEINTERNAL
|
||||
NS_FORWARD_NSIPREFBRANCH(sRootBranch->)
|
||||
NS_FORWARD_NSIPREFBRANCH2(sRootBranch->)
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
@ -341,6 +339,14 @@ public:
|
|||
static nsresult GetDefaultComplex(const char* aPref, const nsIID &aType,
|
||||
void** aResult);
|
||||
|
||||
// Used to synchronise preferences between chrome and content processes.
|
||||
static nsresult ReadExtensionPrefs(nsIFile *aFile);
|
||||
static void MirrorPreferences(nsTArray<PrefTuple,
|
||||
nsTArrayInfallibleAllocator> *aArray);
|
||||
static bool MirrorPreference(const char *aPref, PrefTuple *aTuple);
|
||||
static void ClearContentPref(const char *aPref);
|
||||
static void SetPreference(const PrefTuple *aTuple);
|
||||
|
||||
protected:
|
||||
nsresult NotifyServiceObservers(const char *aSubject);
|
||||
nsresult UseDefaultPrefFile();
|
||||
|
|
|
@ -163,29 +163,6 @@ interface nsIPrefService : nsISupports
|
|||
|
||||
};
|
||||
|
||||
[scriptable, uuid(08c8cd2f-8345-45ee-938d-37ee6d3661b2)]
|
||||
interface nsIPrefServiceInternal : nsISupports
|
||||
{
|
||||
/**
|
||||
* Called to read the preferences in the defaults/preferences/
|
||||
* directory of a zip file
|
||||
*
|
||||
* @param aFile The zip file to be read.
|
||||
*
|
||||
* @return NS_OK The file was read and processed.
|
||||
* @return Other The file failed to read or contained invalid data.
|
||||
*
|
||||
* @see readUserPrefs
|
||||
*/
|
||||
void readExtensionPrefs(in nsILocalFile aFile);
|
||||
|
||||
[noscript] void mirrorPreferences(in nsPreferencesArrayPtr aArray);
|
||||
[noscript] void mirrorPreference(in ACString aPrefName, in nsPreferencePtr aPref);
|
||||
[noscript] boolean prefHasUserValue(in ACString aPrefName);
|
||||
[noscript] void setPreference(in nsPreferencePtrConst aPref);
|
||||
[noscript] void clearContentPref(in ACString aPrefName);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
||||
#define NS_PREFSERVICE_CID \
|
||||
|
|
|
@ -303,7 +303,6 @@ NS_IMPL_THREADSAFE_RELEASE(Preferences)
|
|||
NS_INTERFACE_MAP_BEGIN(Preferences)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPrefService)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPrefService)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPrefServiceInternal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPrefBranch)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPrefBranch2)
|
||||
|
@ -463,9 +462,8 @@ Preferences::SavePrefFile(nsIFile *aFile)
|
|||
return SavePrefFileInternal(aFile);
|
||||
}
|
||||
|
||||
/* part of nsIPrefServiceInternal */
|
||||
NS_IMETHODIMP
|
||||
Preferences::ReadExtensionPrefs(nsILocalFile *aFile)
|
||||
nsresult
|
||||
Preferences::ReadExtensionPrefs(nsIFile *aFile)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIZipReader> reader = do_CreateInstance(kZipReaderCID, &rv);
|
||||
|
@ -513,47 +511,35 @@ Preferences::ReadExtensionPrefs(nsILocalFile *aFile)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Preferences::PrefHasUserValue(const nsACString& aPrefName, bool* aHasValue)
|
||||
{
|
||||
*aHasValue = PREF_HasUserPref(aPrefName.BeginReading());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
Preferences::SetPreference(const PrefTuple *aPref)
|
||||
{
|
||||
return pref_SetPrefTuple(*aPref, true);
|
||||
pref_SetPrefTuple(*aPref, true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Preferences::ClearContentPref(const nsACString& aPrefName)
|
||||
void
|
||||
Preferences::ClearContentPref(const char *aPref)
|
||||
{
|
||||
return PREF_ClearUserPref(aPrefName.BeginReading());
|
||||
PREF_ClearUserPref(aPref);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Preferences::MirrorPreference(const nsACString& aPrefName, PrefTuple *aPref)
|
||||
bool
|
||||
Preferences::MirrorPreference(const char *aPref, PrefTuple *aTuple)
|
||||
{
|
||||
PrefHashEntry *pref = pref_HashTableLookup(PromiseFlatCString(aPrefName).get());
|
||||
PrefHashEntry *entry = pref_HashTableLookup(aPref);
|
||||
if (!entry)
|
||||
return false;
|
||||
|
||||
if (!pref)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
pref_GetTupleFromEntry(pref, aPref);
|
||||
|
||||
return NS_OK;
|
||||
pref_GetTupleFromEntry(entry, aTuple);
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
Preferences::MirrorPreferences(nsTArray<PrefTuple,
|
||||
nsTArrayInfallibleAllocator> *aArray)
|
||||
{
|
||||
aArray->SetCapacity(PL_DHASH_TABLE_SIZE(&gHashTable));
|
||||
|
||||
PL_DHashTableEnumerate(&gHashTable, pref_MirrorPrefs, aArray);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include "nsILocalFile.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIProfileChangeStatus.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIToolkitChromeRegistry.h"
|
||||
|
@ -68,6 +67,7 @@
|
|||
#include "nsReadableUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Omnijar.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -508,7 +508,7 @@ LoadExtensionDirectories(nsINIParser &parser,
|
|||
{
|
||||
nsresult rv;
|
||||
PRInt32 i = 0;
|
||||
nsCOMPtr<nsIPrefServiceInternal> prefs =
|
||||
nsCOMPtr<nsIPrefService> prefs =
|
||||
do_GetService("@mozilla.org/preferences-service;1");
|
||||
do {
|
||||
nsCAutoString buf("Extension");
|
||||
|
@ -531,7 +531,7 @@ LoadExtensionDirectories(nsINIParser &parser,
|
|||
XRE_AddJarManifestLocation(aType, dir);
|
||||
if (!prefs)
|
||||
continue;
|
||||
prefs->ReadExtensionPrefs(dir);
|
||||
mozilla::Preferences::ReadExtensionPrefs(dir);
|
||||
}
|
||||
else {
|
||||
aDirectories.AppendObject(dir);
|
||||
|
|
Загрузка…
Ссылка в новой задаче