diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 099ab79f636..a21a644cb2b 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -148,7 +148,6 @@ #include "nsIJSContextStack.h" #include "nsIJSRuntimeService.h" #include "nsIMarkupDocumentViewer.h" -#include "nsIPrefBranch.h" #include "nsIPresShell.h" #include "nsIPrivateDOMEvent.h" #include "nsIProgrammingLanguage.h" diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 5ea02266466..ba5d5ad0be5 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -49,8 +49,6 @@ #include "nsIFilePicker.h" #include "nsIWindowWatcher.h" #include "nsIDOMWindow.h" -#include "nsIPrefBranch.h" -#include "nsIPrefLocalizedString.h" #include "nsIObserverService.h" #include "nsContentUtils.h" #include "nsAutoPtr.h" @@ -216,10 +214,7 @@ ContentParent::Init() obs->AddObserver(this, "a11y-init-or-shutdown", false); #endif } - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefs) { - prefs->AddObserver("", this, false); - } + Preferences::AddStrongObserver(this, ""); nsCOMPtr threadInt(do_QueryInterface(NS_GetCurrentThread())); if (threadInt) { @@ -249,13 +244,8 @@ ContentParent::OnChannelConnected(int32 pid) SetOtherProcess(handle); #if defined(ANDROID) || defined(LINUX) - EnsurePrefService(); - nsCOMPtr branch; - branch = do_QueryInterface(mPrefService); - // Check nice preference - PRInt32 nice = 0; - branch->GetIntPref("dom.ipc.content.nice", &nice); + PRInt32 nice = Preferences::GetInt("dom.ipc.content.nice", 0); // Environment variable overrides preference char* relativeNicenessStr = getenv("MOZ_CHILD_PROCESS_RELATIVE_NICENESS"); @@ -329,11 +319,7 @@ ContentParent::ActorDestroy(ActorDestroyReason why) SetChildMemoryReporters(empty); // remove the global remote preferences observers - nsCOMPtr prefs - (do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefs) { - prefs->RemoveObserver("", this); - } + Preferences::RemoveObserver(this, ""); RecvRemoveGeolocationListener(); @@ -464,7 +450,6 @@ ContentParent::IsAlive() bool ContentParent::RecvReadPrefsArray(InfallibleTArray *prefs) { - EnsurePrefService(); Preferences::MirrorPreferences(prefs); return true; } @@ -478,18 +463,6 @@ ContentParent::RecvReadFontList(InfallibleTArray* retValue) return true; } - -void -ContentParent::EnsurePrefService() -{ - nsresult rv; - if (!mPrefService) { - mPrefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); - NS_ASSERTION(NS_SUCCEEDED(rv), - "We lost prefService in the Chrome process !"); - } -} - bool ContentParent::RecvReadPermissions(InfallibleTArray* aPermissions) { diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index c768a5769f8..5c044fc2254 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -48,7 +48,6 @@ #include "nsIObserver.h" #include "nsIThreadInternal.h" #include "nsNetUtil.h" -#include "nsIPrefService.h" #include "nsIPermissionManager.h" #include "nsIDOMGeoPositionCallback.h" #include "nsIMemoryReporter.h" @@ -167,8 +166,6 @@ private: virtual bool RecvReadPrefsArray(InfallibleTArray *retValue); virtual bool RecvReadFontList(InfallibleTArray* retValue); - void EnsurePrefService(); - virtual bool RecvReadPermissions(InfallibleTArray* aPermissions); virtual bool RecvGetIndexedDBDirectory(nsString* aDirectory); @@ -238,8 +235,6 @@ private: nsCOMArray mMemoryReporters; bool mIsAlive; - nsCOMPtr mPrefService; - bool mSendPermissionUpdates; nsRefPtr mMessageManager; diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index cbbde291f9a..1e195512145 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -55,12 +55,11 @@ #include "nsIServiceManager.h" #include "nsThreadUtils.h" #include "nsIPrivateBrowsingService.h" +#include "mozilla/Preferences.h" #include "nsIPluginStreamListener.h" #include "nsPluginsDir.h" #include "nsPluginSafety.h" -#include "nsIPrefService.h" -#include "nsIPrefBranch.h" #include "nsPluginLogging.h" #include "nsIJSContextStack.h" @@ -352,7 +351,7 @@ nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag) } #endif - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); + nsIPrefBranch* prefs = Preferences::GetRootBranch(); if (!prefs) { return false; } @@ -385,8 +384,7 @@ nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag) // so use the mime type (mIsJavaPlugin) and a special pref. bool javaIsEnabled; if (aPluginTag->mIsJavaPlugin && - NS_SUCCEEDED(prefs->GetBoolPref("dom.ipc.plugins.java.enabled", &javaIsEnabled)) && - !javaIsEnabled) { + !Preferences::GetBool("dom.ipc.plugins.java.enabled", true)) { return false; } @@ -417,8 +415,8 @@ nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag) match = (NS_WildCardMatch(prefFile.get(), maskStart, 0) == MATCH); } - if (match && NS_SUCCEEDED(prefs->GetBoolPref(prefNames[currentPref], - &oopPluginsEnabled))) { + if (match && NS_SUCCEEDED(Preferences::GetBool(prefNames[currentPref], + &oopPluginsEnabled))) { prefSet = true; break; } @@ -427,17 +425,17 @@ nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag) } if (!prefSet) { - oopPluginsEnabled = false; + oopPluginsEnabled = #ifdef XP_MACOSX #if defined(__i386__) - prefs->GetBoolPref("dom.ipc.plugins.enabled.i386", &oopPluginsEnabled); + Preferences::GetBool("dom.ipc.plugins.enabled.i386", false); #elif defined(__x86_64__) - prefs->GetBoolPref("dom.ipc.plugins.enabled.x86_64", &oopPluginsEnabled); + Preferences::GetBool("dom.ipc.plugins.enabled.x86_64", false); #elif defined(__ppc__) - prefs->GetBoolPref("dom.ipc.plugins.enabled.ppc", &oopPluginsEnabled); + Preferences::GetBool("dom.ipc.plugins.enabled.ppc", false); #endif #else - prefs->GetBoolPref("dom.ipc.plugins.enabled", &oopPluginsEnabled); + Preferences::GetBool("dom.ipc.plugins.enabled", false); #endif } @@ -2061,12 +2059,10 @@ _getvalue(NPP npp, NPNVariable variable, void *result) case NPNVjavascriptEnabledBool: { *(NPBool*)result = false; - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefs) { - bool js = false;; - res = prefs->GetBoolPref("javascript.enabled", &js); - if (NS_SUCCEEDED(res)) - *(NPBool*)result = js; + bool js = false; + res = Preferences::GetBool("javascript.enabled", &js); + if (NS_SUCCEEDED(res)) { + *(NPBool*)result = js; } return NPERR_NO_ERROR; } diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index 21ae9368fc2..4d5f091284b 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -61,6 +61,8 @@ #include "nsNetCID.h" #include "nsIContent.h" +#include "mozilla/Preferences.h" + #ifdef MOZ_WIDGET_ANDROID #include "ANPBase.h" #include @@ -105,13 +107,8 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance() mNPP.pdata = NULL; mNPP.ndata = this; - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefs) { - bool useLayersPref; - nsresult rv = prefs->GetBoolPref("plugins.use_layers", &useLayersPref); - if (NS_SUCCEEDED(rv)) - mUsePluginLayersPref = useLayersPref; - } + mUsePluginLayersPref = + Preferences::GetBool("plugins.use_layers", mUsePluginLayersPref); PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this)); } diff --git a/dom/plugins/base/nsPluginDirServiceProvider.cpp b/dom/plugins/base/nsPluginDirServiceProvider.cpp index ff3e68a07f8..7d2545ef78b 100644 --- a/dom/plugins/base/nsPluginDirServiceProvider.cpp +++ b/dom/plugins/base/nsPluginDirServiceProvider.cpp @@ -41,16 +41,16 @@ #include "nsCRT.h" #include "nsILocalFile.h" -#include "nsIPrefBranch.h" -#include "nsIPrefService.h" #include "nsDependentString.h" -#include "nsXPIDLString.h" #include "prmem.h" #include "nsArrayEnumerator.h" +#include "mozilla/Preferences.h" #include #include "nsIWindowsRegKey.h" +using namespace mozilla; + typedef struct structVer { WORD wMajor; @@ -231,18 +231,15 @@ nsPluginDirServiceProvider::GetFile(const char *charProp, bool *persistant, *_retval = nsnull; *persistant = false; - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (!prefs) - return NS_ERROR_FAILURE; - nsCOMPtr regKey = do_CreateInstance("@mozilla.org/windows-registry-key;1"); NS_ENSURE_TRUE(regKey, NS_ERROR_FAILURE); if (nsCRT::strcmp(charProp, NS_WIN_JRE_SCAN_KEY) == 0) { - nsXPIDLCString strVer; - if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) + nsAdoptingCString strVer = Preferences::GetCString(charProp); + if (!strVer) { return NS_ERROR_FAILURE; + } verBlock minVer; TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer); @@ -332,9 +329,10 @@ nsPluginDirServiceProvider::GetFile(const char *charProp, bool *persistant, } } } else if (nsCRT::strcmp(charProp, NS_WIN_QUICKTIME_SCAN_KEY) == 0) { - nsXPIDLCString strVer; - if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) + nsAdoptingCString strVer = Preferences::GetCString(charProp); + if (!strVer) { return NS_ERROR_FAILURE; + } verBlock minVer; TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer); @@ -371,9 +369,10 @@ nsPluginDirServiceProvider::GetFile(const char *charProp, bool *persistant, } } } else if (nsCRT::strcmp(charProp, NS_WIN_WMP_SCAN_KEY) == 0) { - nsXPIDLCString strVer; - if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) + nsAdoptingCString strVer = Preferences::GetCString(charProp); + if (!strVer) { return NS_ERROR_FAILURE; + } verBlock minVer; TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer); @@ -409,8 +408,8 @@ nsPluginDirServiceProvider::GetFile(const char *charProp, bool *persistant, } } } else if (nsCRT::strcmp(charProp, NS_WIN_ACROBAT_SCAN_KEY) == 0) { - nsXPIDLCString strVer; - if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) { + nsAdoptingCString strVer = Preferences::GetCString(charProp); + if (!strVer) { return NS_ERROR_FAILURE; } diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index d37ef12c9dc..2edead6b53c 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -80,7 +80,6 @@ #include "nsHashtable.h" #include "nsIProxyInfo.h" #include "nsPluginLogging.h" -#include "nsIPrefBranch.h" #include "nsIScriptChannel.h" #include "nsIBlocklistService.h" #include "nsVersionComparator.h" @@ -88,6 +87,7 @@ #include "nsIObjectLoadingContent.h" #include "nsIWritablePropertyBag2.h" #include "nsPluginStreamListenerPeer.h" +#include "mozilla/Preferences.h" #include "nsEnumeratorUtils.h" #include "nsXPCOM.h" @@ -336,17 +336,7 @@ NS_IMETHODIMP nsPluginDocReframeEvent::Run() { static bool UnloadPluginsASAP() { - nsresult rv; - nsCOMPtr pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); - if (NS_SUCCEEDED(rv)) { - bool unloadPluginsASAP = false; - rv = pref->GetBoolPref("dom.ipc.plugins.unloadASAP", &unloadPluginsASAP); - if (NS_SUCCEEDED(rv)) { - return unloadPluginsASAP; - } - } - - return false; + return Preferences::GetBool("dom.ipc.plugins.unloadASAP", false); } nsPluginHost::nsPluginHost() @@ -355,20 +345,10 @@ nsPluginHost::nsPluginHost() { // check to see if pref is set at startup to let plugins take over in // full page mode for certain image mime types that we handle internally - mPrefService = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (mPrefService) { - bool tmp; - nsresult rv = mPrefService->GetBoolPref("plugin.override_internal_types", - &tmp); - if (NS_SUCCEEDED(rv)) { - mOverrideInternalTypes = tmp; - } + mOverrideInternalTypes = + Preferences::GetBool("plugin.override_internal_types", false); - rv = mPrefService->GetBoolPref("plugin.disable", &tmp); - if (NS_SUCCEEDED(rv)) { - mPluginsDisabled = tmp; - } - } + mPluginsDisabled = Preferences::GetBool("plugin.disable", false); nsCOMPtr obsService = mozilla::services::GetObserverService(); @@ -866,8 +846,6 @@ nsresult nsPluginHost::Destroy() } #endif /* XP_WIN */ - mPrefService = nsnull; // release prefs service to avoid leaks! - return NS_OK; } @@ -1454,11 +1432,7 @@ public: NS_METHOD GetFilename(nsAString& aFilename) { - bool bShowPath; - nsCOMPtr prefService = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefService && - NS_SUCCEEDED(prefService->GetBoolPref("plugin.expose_full_path", &bShowPath)) && - bShowPath) { + if (Preferences::GetBool("plugin.expose_full_path", false)) { CopyUTF8toUTF16(mPluginTag.mFullPath, aFilename); } else { CopyUTF8toUTF16(mPluginTag.mFileName, aFilename); @@ -2219,7 +2193,7 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir, } if (warnOutdated) { - mPrefService->SetBoolPref("plugins.update.notifyUser", true); + Preferences::SetBool("plugins.update.notifyUser", true); } return NS_OK; @@ -2348,10 +2322,7 @@ nsresult nsPluginHost::FindPlugins(bool aCreatePluginList, bool * aPluginsChange // the rest is optional #ifdef XP_WIN - bool bScanPLIDs = false; - - if (mPrefService) - mPrefService->GetBoolPref("plugin.scan.plid.all", &bScanPLIDs); + bool bScanPLIDs = Preferences::GetBool("plugin.scan.plid.all", false); // Now lets scan any PLID directories if (bScanPLIDs && mPrivateDirServiceProvider) { @@ -3233,13 +3204,9 @@ nsPluginHost::StopPluginInstance(nsNPAPIPluginInstance* aInstance) bool doCache = aInstance->ShouldCache(); if (doCache) { // try to get the max cached instances from a pref or use default - PRUint32 cachedInstanceLimit; - nsresult rv = NS_ERROR_FAILURE; - if (mPrefService) - rv = mPrefService->GetIntPref(NS_PREF_MAX_NUM_CACHED_INSTANCES, (int*)&cachedInstanceLimit); - if (NS_FAILED(rv)) - cachedInstanceLimit = DEFAULT_NUMBER_OF_STOPPED_INSTANCES; - + PRUint32 cachedInstanceLimit = + Preferences::GetUint(NS_PREF_MAX_NUM_CACHED_INSTANCES, + DEFAULT_NUMBER_OF_STOPPED_INSTANCES); if (StoppedInstanceCount() >= cachedInstanceLimit) { nsNPAPIPluginInstance *oldestInstance = FindOldestStoppedInstance(); if (oldestInstance) { diff --git a/dom/plugins/base/nsPluginHost.h b/dom/plugins/base/nsPluginHost.h index 4ca265a514a..a840706fe91 100644 --- a/dom/plugins/base/nsPluginHost.h +++ b/dom/plugins/base/nsPluginHost.h @@ -53,7 +53,6 @@ #include "nsWeakPtr.h" #include "nsIPrompt.h" #include "nsISupportsArray.h" -#include "nsIPrefBranch.h" #include "nsWeakReference.h" #include "nsThreadUtils.h" #include "nsTArray.h" @@ -322,7 +321,6 @@ private: nsTArray< nsRefPtr > mInstances; nsCOMPtr mPluginRegFile; - nsCOMPtr mPrefService; #ifdef XP_WIN nsRefPtr mPrivateDirServiceProvider; #endif diff --git a/dom/plugins/base/nsPluginSafety.h b/dom/plugins/base/nsPluginSafety.h index 801c8464eaa..98e8f4ccde7 100644 --- a/dom/plugins/base/nsPluginSafety.h +++ b/dom/plugins/base/nsPluginSafety.h @@ -40,8 +40,6 @@ #include "npapi.h" #include "nsPluginHost.h" -#include "nsIPrefBranch.h" -#include "nsIPrefService.h" #include #if defined(XP_WIN) @@ -52,14 +50,15 @@ void NS_NotifyPluginCall(PRIntervalTime); #ifdef CALL_SAFETY_ON +#include "mozilla/Preferences.h" + extern bool gSkipPluginSafeCalls; -#define NS_INIT_PLUGIN_SAFE_CALLS \ -PR_BEGIN_MACRO \ - nsresult res; \ - nsCOMPtr pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &res)); \ - if(NS_SUCCEEDED(res) && pref) \ - res = pref->GetBoolPref("plugin.dont_try_safe_calls", &gSkipPluginSafeCalls);\ +#define NS_INIT_PLUGIN_SAFE_CALLS \ +PR_BEGIN_MACRO \ + gSkipPluginSafeCalls = \ + ::mozilla::Preferences::GetBool("plugin.dont_try_safe_calls", \ + gSkipPluginSafeCalls); \ PR_END_MACRO #define NS_TRY_SAFE_CALL_RETURN(ret, fun, pluginInst) \ diff --git a/dom/plugins/base/nsPluginTags.cpp b/dom/plugins/base/nsPluginTags.cpp index f6bc5b4a707..f8d8050be09 100644 --- a/dom/plugins/base/nsPluginTags.cpp +++ b/dom/plugins/base/nsPluginTags.cpp @@ -45,8 +45,6 @@ #include "nsIPluginInstanceOwner.h" #include "nsIDocument.h" #include "nsServiceManagerUtils.h" -#include "nsIPrefService.h" -#include "nsIPrefBranch.h" #include "nsPluginsDir.h" #include "nsPluginHost.h" #include "nsIUnicodeDecoder.h" @@ -56,7 +54,9 @@ #include "nsICategoryManager.h" #include "nsNPAPIPlugin.h" #include "mozilla/TimeStamp.h" +#include "mozilla/Preferences.h" +using namespace mozilla; using mozilla::TimeStamp; inline char* new_str(const char* str) @@ -388,10 +388,6 @@ nsPluginTag::RegisterWithCategoryManager(bool aOverrideInternalTypes, const char *contractId = "@mozilla.org/content/plugin/document-loader-factory;1"; - nsCOMPtr psvc(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (!psvc) - return; // NS_ERROR_OUT_OF_MEMORY - // A preference controls whether or not the full page plugin is disabled for // a particular type. The string must be in the form: // type1,type2,type3,type4 @@ -399,11 +395,11 @@ nsPluginTag::RegisterWithCategoryManager(bool aOverrideInternalTypes, // (and other plugin host settings) so applications can reliably disable // plugins - without relying on implementation details such as prefs/category // manager entries. - nsXPIDLCString overrideTypes; nsCAutoString overrideTypesFormatted; if (aType != ePluginUnregister) { - psvc->GetCharPref("plugin.disable_full_page_plugin_for_types", getter_Copies(overrideTypes)); overrideTypesFormatted.Assign(','); + nsAdoptingCString overrideTypes = + Preferences::GetCString("plugin.disable_full_page_plugin_for_types"); overrideTypesFormatted += overrideTypes; overrideTypesFormatted.Append(','); } diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index 1fa1adb2a7c..293249254ed 100644 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -41,8 +41,6 @@ #elif XP_MACOSX #include "PluginInterposeOSX.h" #include "PluginUtilsOSX.h" -#include "nsIPrefService.h" -#include "nsIPrefBranch.h" #endif #ifdef MOZ_WIDGET_QT #include @@ -1163,15 +1161,8 @@ PluginModuleParent::RecvGetNativeCursorsSupported(bool* supported) { PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION)); #if defined(XP_MACOSX) - bool nativeCursorsSupported = false; - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefs) { - if (NS_FAILED(prefs->GetBoolPref("dom.ipc.plugins.nativeCursorSupport", - &nativeCursorsSupported))) { - nativeCursorsSupported = false; - } - } - *supported = nativeCursorsSupported; + *supported = + Preferences::GetBool("dom.ipc.plugins.nativeCursorSupport", false); return true; #else NS_NOTREACHED( diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index 3bb87b40e68..26078edab4e 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -66,8 +66,6 @@ #include "nsIURI.h" #include "nsIPermissionManager.h" #include "nsIObserverService.h" -#include "nsIPrefService.h" -#include "nsIPrefBranch.h" #include "nsIJSContextStack.h" #include "nsThreadUtils.h" #include "mozilla/Services.h" diff --git a/dom/src/storage/nsDOMStorage.cpp b/dom/src/storage/nsDOMStorage.cpp index 116752d6ca1..d3e7ff85e8d 100644 --- a/dom/src/storage/nsDOMStorage.cpp +++ b/dom/src/storage/nsDOMStorage.cpp @@ -61,7 +61,6 @@ using mozilla::dom::StorageChild; #include "nsReadableUtils.h" #include "nsIObserverService.h" #include "nsNetUtil.h" -#include "nsIPrefBranch.h" #include "nsICookiePermission.h" #include "nsIPermission.h" #include "nsIPermissionManager.h" diff --git a/dom/system/nsDeviceSensors.cpp b/dom/system/nsDeviceSensors.cpp index d350929dc04..227a35601df 100644 --- a/dom/system/nsDeviceSensors.cpp +++ b/dom/system/nsDeviceSensors.cpp @@ -48,7 +48,8 @@ #include "nsIServiceManager.h" #include "nsIPrivateDOMEvent.h" #include "nsIServiceManager.h" -#include "nsIPrefService.h" + +#include "mozilla/Preferences.h" using namespace mozilla; using namespace hal; @@ -122,17 +123,9 @@ NS_IMETHODIMP nsDeviceSensorData::GetZ(double *aZ) NS_IMPL_ISUPPORTS1(nsDeviceSensors, nsIDeviceSensors) nsDeviceSensors::nsDeviceSensors() -: mEnabled(true) { mLastDOMMotionEventTime = TimeStamp::Now(); - - nsCOMPtr prefSrv = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefSrv) { - bool bvalue; - nsresult rv = prefSrv->GetBoolPref("device.motion.enabled", &bvalue); - if (NS_SUCCEEDED(rv) && bvalue == false) - mEnabled = false; - } + mEnabled = Preferences::GetBool("device.motion.enabled", true); for (int i = 0; i < NUM_SENSOR_TYPE; i++) { nsTArray *windows = new nsTArray(); diff --git a/dom/system/unix/MaemoLocationProvider.cpp b/dom/system/unix/MaemoLocationProvider.cpp index 440e3c3a239..1412109fe0c 100644 --- a/dom/system/unix/MaemoLocationProvider.cpp +++ b/dom/system/unix/MaemoLocationProvider.cpp @@ -41,10 +41,11 @@ #include "MaemoLocationProvider.h" #include "nsIClassInfo.h" #include "nsDOMClassInfoID.h" -#include "nsIPrefService.h" -#include "nsIPrefBranch.h" #include "nsIServiceManager.h" #include "nsServiceManagerUtils.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; NS_IMPL_ISUPPORTS2(MaemoLocationProvider, nsIGeolocationProvider, nsITimerCallback) @@ -192,31 +193,31 @@ NS_IMETHODIMP MaemoLocationProvider::Startup() { nsresult rv(NS_OK); - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (!prefs) - return NS_ERROR_FAILURE; - rv = StartControl(); NS_ENSURE_SUCCESS(rv, rv); rv = StartDevice(); NS_ENSURE_SUCCESS(rv, rv); - prefs->GetBoolPref("geo.herror.ignore.big", &mIgnoreBigHErr); + mIgnoreBigHErr = + Preferences::GetBool("geo.herror.ignore.big", mIgnoreBigHErr); - if (mIgnoreBigHErr) - prefs->GetIntPref("geo.herror.max.value", &mMaxHErr); + if (mIgnoreBigHErr) { + mMaxHErr = Preferences::GetInt("geo.herror.max.value", mMaxHErr); + } - prefs->GetBoolPref("geo.verror.ignore.big", &mIgnoreBigVErr); + mIgnoreBigVErr = + Preferences::GetBool("geo.verror.ignore.big", mIgnoreBigVErr); - if (mIgnoreBigVErr) - prefs->GetIntPref("geo.verror.max.value", &mMaxVErr); + if (mIgnoreBigVErr) { + mMaxVErr = Preferences::GetInt("geo.verror.max.value", mMaxVErr); + } if (mUpdateTimer) return NS_OK; - PRInt32 update = 0; //0 second no timer created - prefs->GetIntPref("geo.default.update", &update); + // 0 second no timer created + PRInt32 update = Preferences::GetInt("geo.default.update", 0); if (!update) return NS_OK;