2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
2001-03-23 02:34:41 +03:00
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
#ifndef mozilla_Preferences_h
|
|
|
|
#define mozilla_Preferences_h
|
|
|
|
|
|
|
|
#ifndef MOZILLA_INTERNAL_API
|
|
|
|
#error "This header is only usable from within libxul (MOZILLA_INTERNAL_API)."
|
|
|
|
#endif
|
2004-05-05 18:42:55 +04:00
|
|
|
|
2001-03-23 02:34:41 +03:00
|
|
|
#include "nsIPrefService.h"
|
2001-04-04 00:11:54 +04:00
|
|
|
#include "nsIPrefBranch.h"
|
|
|
|
#include "nsIPrefBranchInternal.h"
|
2001-03-23 02:34:41 +03:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2012-08-23 00:00:21 +04:00
|
|
|
#include "nsTArray.h"
|
2001-06-19 05:40:19 +04:00
|
|
|
#include "nsWeakReference.h"
|
2013-01-18 04:45:11 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2001-03-23 02:34:41 +03:00
|
|
|
|
|
|
|
class nsIFile;
|
2011-05-28 11:03:00 +04:00
|
|
|
class nsAdoptingString;
|
|
|
|
class nsAdoptingCString;
|
2001-03-23 02:34:41 +03:00
|
|
|
|
2011-05-29 03:42:57 +04:00
|
|
|
#ifndef have_PrefChangedFunc_typedef
|
2013-12-11 03:10:01 +04:00
|
|
|
typedef void (*PrefChangedFunc)(const char *, void *);
|
2011-05-29 03:42:57 +04:00
|
|
|
#define have_PrefChangedFunc_typedef
|
|
|
|
#endif
|
|
|
|
|
2011-05-23 18:54:02 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
2012-08-23 00:00:21 +04:00
|
|
|
namespace dom {
|
|
|
|
class PrefSetting;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2012-08-23 00:00:21 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class Preferences final : public nsIPrefService,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIObserver,
|
|
|
|
public nsIPrefBranchInternal,
|
|
|
|
public nsSupportsWeakReference
|
2001-03-23 02:34:41 +03:00
|
|
|
{
|
|
|
|
public:
|
2012-08-23 00:00:21 +04:00
|
|
|
typedef mozilla::dom::PrefSetting PrefSetting;
|
|
|
|
|
2013-07-19 06:23:44 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2001-03-23 02:34:41 +03:00
|
|
|
NS_DECL_NSIPREFSERVICE
|
2011-06-22 10:39:10 +04:00
|
|
|
NS_FORWARD_NSIPREFBRANCH(sRootBranch->)
|
2001-03-23 02:34:41 +03:00
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2011-05-23 18:54:02 +04:00
|
|
|
Preferences();
|
2001-03-23 02:34:41 +03:00
|
|
|
|
2001-04-04 00:11:54 +04:00
|
|
|
nsresult Init();
|
2011-05-23 18:54:03 +04:00
|
|
|
|
2011-11-08 09:20:42 +04:00
|
|
|
/**
|
|
|
|
* Reset loaded user prefs then read them
|
|
|
|
*/
|
|
|
|
static nsresult ResetAndReadUserPrefs();
|
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
/**
|
|
|
|
* Returns the singleton instance which is addreffed.
|
|
|
|
*/
|
2011-06-12 06:30:15 +04:00
|
|
|
static Preferences* GetInstanceForService();
|
2011-05-23 18:54:03 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Finallizes global members.
|
|
|
|
*/
|
|
|
|
static void Shutdown();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns shared pref service instance
|
|
|
|
* NOTE: not addreffed.
|
|
|
|
*/
|
2011-06-03 10:01:02 +04:00
|
|
|
static nsIPrefService* GetService()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(InitStaticMembers(), nullptr);
|
2011-06-03 10:01:02 +04:00
|
|
|
return sPreferences;
|
|
|
|
}
|
2011-05-23 18:54:03 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns shared pref branch instance.
|
|
|
|
* NOTE: not addreffed.
|
|
|
|
*/
|
2012-01-16 12:47:13 +04:00
|
|
|
static nsIPrefBranch* GetRootBranch()
|
2011-05-23 18:54:03 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(InitStaticMembers(), nullptr);
|
2011-06-22 10:39:10 +04:00
|
|
|
return sRootBranch;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns shared default pref branch instance.
|
|
|
|
* NOTE: not addreffed.
|
|
|
|
*/
|
|
|
|
static nsIPrefBranch* GetDefaultRootBranch()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(InitStaticMembers(), nullptr);
|
2011-06-22 10:39:10 +04:00
|
|
|
return sDefaultRootBranch;
|
2011-05-23 18:54:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets int or bool type pref value with default value if failed to get
|
|
|
|
* the pref.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool GetBool(const char* aPref, bool aDefault = false)
|
2011-05-23 18:54:03 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool result = aDefault;
|
2011-05-23 18:54:03 +04:00
|
|
|
GetBool(aPref, &result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t GetInt(const char* aPref, int32_t aDefault = 0)
|
2011-05-23 18:54:03 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t result = aDefault;
|
2011-05-23 18:54:03 +04:00
|
|
|
GetInt(aPref, &result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t GetUint(const char* aPref, uint32_t aDefault = 0)
|
2011-05-25 10:31:59 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t result = aDefault;
|
2011-05-25 10:31:59 +04:00
|
|
|
GetUint(aPref, &result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-01-10 10:10:52 +04:00
|
|
|
static float GetFloat(const char* aPref, float aDefault = 0)
|
|
|
|
{
|
|
|
|
float result = aDefault;
|
|
|
|
GetFloat(aPref, &result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-06-22 10:39:10 +04:00
|
|
|
/**
|
|
|
|
* Gets char type pref value directly. If failed, the get() of result
|
2013-10-24 00:36:26 +04:00
|
|
|
* returns nullptr. Even if succeeded but the result was empty string, the
|
|
|
|
* get() does NOT return nullptr. So, you can check whether the method
|
2011-06-22 10:39:10 +04:00
|
|
|
* succeeded or not by:
|
|
|
|
*
|
|
|
|
* nsAdoptingString value = Prefereces::GetString("foo.bar");
|
|
|
|
* if (!value) {
|
|
|
|
* // failed
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* Be aware. If you wrote as:
|
|
|
|
*
|
|
|
|
* nsAutoString value = Preferences::GetString("foo.bar");
|
|
|
|
* if (!value.get()) {
|
|
|
|
* // the condition is always FALSE!!
|
|
|
|
* }
|
|
|
|
*
|
2013-10-24 00:36:26 +04:00
|
|
|
* The value.get() doesn't return nullptr. You must use nsAdoptingString
|
|
|
|
* when you need to check whether it was failure or not.
|
2011-06-22 10:39:10 +04:00
|
|
|
*/
|
2011-05-28 11:03:00 +04:00
|
|
|
static nsAdoptingCString GetCString(const char* aPref);
|
|
|
|
static nsAdoptingString GetString(const char* aPref);
|
|
|
|
static nsAdoptingCString GetLocalizedCString(const char* aPref);
|
|
|
|
static nsAdoptingString GetLocalizedString(const char* aPref);
|
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
/**
|
2012-09-27 00:53:37 +04:00
|
|
|
* Gets int, float, or bool type pref value with raw return value of
|
|
|
|
* nsIPrefBranch.
|
2011-05-23 18:54:03 +04:00
|
|
|
*
|
|
|
|
* @param aPref A pref name.
|
2013-10-24 00:36:26 +04:00
|
|
|
* @param aResult Must not be nullptr. The value is never modified
|
|
|
|
* when these methods fail.
|
2011-05-23 18:54:03 +04:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
static nsresult GetBool(const char* aPref, bool* aResult);
|
2012-08-22 19:56:38 +04:00
|
|
|
static nsresult GetInt(const char* aPref, int32_t* aResult);
|
2012-09-27 00:53:37 +04:00
|
|
|
static nsresult GetFloat(const char* aPref, float* aResult);
|
2012-08-22 19:56:38 +04:00
|
|
|
static nsresult GetUint(const char* aPref, uint32_t* aResult)
|
2011-05-25 10:31:59 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t result;
|
2011-05-25 10:31:59 +04:00
|
|
|
nsresult rv = GetInt(aPref, &result);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2012-08-22 19:56:38 +04:00
|
|
|
*aResult = static_cast<uint32_t>(result);
|
2011-05-25 10:31:59 +04:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
2011-05-23 18:54:03 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets string type pref value with raw return value of nsIPrefBranch.
|
|
|
|
*
|
|
|
|
* @param aPref A pref name.
|
2013-10-24 00:36:26 +04:00
|
|
|
* @param aResult Must not be nullptr. The value is never modified
|
|
|
|
* when these methods fail.
|
2011-05-23 18:54:03 +04:00
|
|
|
*/
|
2011-05-28 11:03:00 +04:00
|
|
|
static nsresult GetCString(const char* aPref, nsACString* aResult);
|
|
|
|
static nsresult GetString(const char* aPref, nsAString* aResult);
|
|
|
|
static nsresult GetLocalizedCString(const char* aPref, nsACString* aResult);
|
|
|
|
static nsresult GetLocalizedString(const char* aPref, nsAString* aResult);
|
2011-05-23 18:54:03 +04:00
|
|
|
|
2011-06-12 06:30:15 +04:00
|
|
|
static nsresult GetComplex(const char* aPref, const nsIID &aType,
|
|
|
|
void** aResult);
|
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
/**
|
|
|
|
* Sets various type pref values.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
static nsresult SetBool(const char* aPref, bool aValue);
|
2012-08-22 19:56:38 +04:00
|
|
|
static nsresult SetInt(const char* aPref, int32_t aValue);
|
|
|
|
static nsresult SetUint(const char* aPref, uint32_t aValue)
|
2011-05-25 10:31:59 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
return SetInt(aPref, static_cast<int32_t>(aValue));
|
2011-05-25 10:31:59 +04:00
|
|
|
}
|
2014-07-11 16:25:12 +04:00
|
|
|
static nsresult SetFloat(const char* aPref, float aValue);
|
2011-05-28 11:03:00 +04:00
|
|
|
static nsresult SetCString(const char* aPref, const char* aValue);
|
|
|
|
static nsresult SetCString(const char* aPref, const nsACString &aValue);
|
2015-10-10 04:19:23 +03:00
|
|
|
static nsresult SetString(const char* aPref, const char16ptr_t aValue);
|
2011-05-28 11:03:00 +04:00
|
|
|
static nsresult SetString(const char* aPref, const nsAString &aValue);
|
2011-05-23 18:54:03 +04:00
|
|
|
|
2011-06-12 06:30:15 +04:00
|
|
|
static nsresult SetComplex(const char* aPref, const nsIID &aType,
|
|
|
|
nsISupports* aValue);
|
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
/**
|
|
|
|
* Clears user set pref.
|
|
|
|
*/
|
|
|
|
static nsresult ClearUser(const char* aPref);
|
|
|
|
|
2011-06-03 10:01:02 +04:00
|
|
|
/**
|
|
|
|
* Whether the pref has a user value or not.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool HasUserValue(const char* aPref);
|
2011-06-03 10:01:02 +04:00
|
|
|
|
2012-04-04 08:06:27 +04:00
|
|
|
/**
|
|
|
|
* Gets the type of the pref.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t GetType(const char* aPref);
|
2012-04-04 08:06:27 +04:00
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
/**
|
|
|
|
* Adds/Removes the observer for the root pref branch.
|
|
|
|
* The observer is referenced strongly if AddStrongObserver is used. On the
|
|
|
|
* other hand, it is referenced weakly, if AddWeakObserver is used.
|
2012-09-15 02:42:35 +04:00
|
|
|
* See nsIPrefBranch.idl for details.
|
2011-05-23 18:54:03 +04:00
|
|
|
*/
|
|
|
|
static nsresult AddStrongObserver(nsIObserver* aObserver, const char* aPref);
|
|
|
|
static nsresult AddWeakObserver(nsIObserver* aObserver, const char* aPref);
|
|
|
|
static nsresult RemoveObserver(nsIObserver* aObserver, const char* aPref);
|
|
|
|
|
2011-05-29 03:39:27 +04:00
|
|
|
/**
|
|
|
|
* Adds/Removes two or more observers for the root pref branch.
|
2013-10-24 00:36:26 +04:00
|
|
|
* Pass to aPrefs an array of const char* whose last item is nullptr.
|
2011-05-29 03:39:27 +04:00
|
|
|
*/
|
|
|
|
static nsresult AddStrongObservers(nsIObserver* aObserver,
|
|
|
|
const char** aPrefs);
|
|
|
|
static nsresult AddWeakObservers(nsIObserver* aObserver,
|
|
|
|
const char** aPrefs);
|
|
|
|
static nsresult RemoveObservers(nsIObserver* aObserver,
|
|
|
|
const char** aPrefs);
|
|
|
|
|
2011-05-29 03:42:57 +04:00
|
|
|
/**
|
|
|
|
* Registers/Unregisters the callback function for the aPref.
|
|
|
|
*/
|
|
|
|
static nsresult RegisterCallback(PrefChangedFunc aCallback,
|
|
|
|
const char* aPref,
|
2012-07-30 18:20:58 +04:00
|
|
|
void* aClosure = nullptr);
|
2011-05-29 03:42:57 +04:00
|
|
|
static nsresult UnregisterCallback(PrefChangedFunc aCallback,
|
|
|
|
const char* aPref,
|
2012-07-30 18:20:58 +04:00
|
|
|
void* aClosure = nullptr);
|
2013-02-20 23:49:49 +04:00
|
|
|
// Like RegisterCallback, but also calls the callback immediately for
|
|
|
|
// initialization.
|
|
|
|
static nsresult RegisterCallbackAndCall(PrefChangedFunc aCallback,
|
|
|
|
const char* aPref,
|
|
|
|
void* aClosure = nullptr);
|
2011-05-29 03:42:57 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the aVariable to cache table. aVariable must be a pointer for a
|
|
|
|
* static variable. The value will be modified when the pref value is
|
|
|
|
* changed but note that even if you modified it, the value isn't assigned to
|
|
|
|
* the pref.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
static nsresult AddBoolVarCache(bool* aVariable,
|
2011-05-29 03:42:57 +04:00
|
|
|
const char* aPref,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aDefault = false);
|
2012-08-22 19:56:38 +04:00
|
|
|
static nsresult AddIntVarCache(int32_t* aVariable,
|
2011-05-29 03:42:57 +04:00
|
|
|
const char* aPref,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aDefault = 0);
|
|
|
|
static nsresult AddUintVarCache(uint32_t* aVariable,
|
2011-05-29 03:42:57 +04:00
|
|
|
const char* aPref,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aDefault = 0);
|
2013-01-10 10:10:52 +04:00
|
|
|
static nsresult AddFloatVarCache(float* aVariable,
|
|
|
|
const char* aPref,
|
|
|
|
float aDefault = 0.0f);
|
2011-05-29 03:42:57 +04:00
|
|
|
|
2011-06-22 10:39:10 +04:00
|
|
|
/**
|
|
|
|
* Gets the default bool, int or uint value of the pref.
|
|
|
|
* The result is raw result of nsIPrefBranch::Get*Pref().
|
|
|
|
* If the pref could have any value, you needed to use these methods.
|
|
|
|
* If not so, you could use below methods.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
static nsresult GetDefaultBool(const char* aPref, bool* aResult);
|
2012-08-22 19:56:38 +04:00
|
|
|
static nsresult GetDefaultInt(const char* aPref, int32_t* aResult);
|
|
|
|
static nsresult GetDefaultUint(const char* aPref, uint32_t* aResult)
|
2011-06-22 10:39:10 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
return GetDefaultInt(aPref, reinterpret_cast<int32_t*>(aResult));
|
2011-06-22 10:39:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the default bool, int or uint value of the pref directly.
|
|
|
|
* You can set an invalid value of the pref to aFailedResult. If these
|
|
|
|
* methods failed to get the default value, they would return the
|
|
|
|
* aFailedResult value.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool GetDefaultBool(const char* aPref, bool aFailedResult)
|
2011-06-22 10:39:10 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool result;
|
2011-06-22 10:39:10 +04:00
|
|
|
return NS_SUCCEEDED(GetDefaultBool(aPref, &result)) ? result :
|
|
|
|
aFailedResult;
|
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t GetDefaultInt(const char* aPref, int32_t aFailedResult)
|
2011-06-22 10:39:10 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t result;
|
2011-06-22 10:39:10 +04:00
|
|
|
return NS_SUCCEEDED(GetDefaultInt(aPref, &result)) ? result : aFailedResult;
|
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t GetDefaultUint(const char* aPref, uint32_t aFailedResult)
|
2011-06-22 10:39:10 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
return static_cast<uint32_t>(
|
|
|
|
GetDefaultInt(aPref, static_cast<int32_t>(aFailedResult)));
|
2011-06-22 10:39:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the default value of the char type pref.
|
2013-10-24 00:36:26 +04:00
|
|
|
* If the get() of the result returned nullptr, that meant the value didn't
|
2011-06-22 10:39:10 +04:00
|
|
|
* have default value.
|
|
|
|
*
|
|
|
|
* See the comment at definition at GetString() and GetCString() for more
|
|
|
|
* details of the result.
|
|
|
|
*/
|
|
|
|
static nsAdoptingString GetDefaultString(const char* aPref);
|
|
|
|
static nsAdoptingCString GetDefaultCString(const char* aPref);
|
|
|
|
static nsAdoptingString GetDefaultLocalizedString(const char* aPref);
|
|
|
|
static nsAdoptingCString GetDefaultLocalizedCString(const char* aPref);
|
|
|
|
|
|
|
|
static nsresult GetDefaultCString(const char* aPref, nsACString* aResult);
|
|
|
|
static nsresult GetDefaultString(const char* aPref, nsAString* aResult);
|
|
|
|
static nsresult GetDefaultLocalizedCString(const char* aPref,
|
|
|
|
nsACString* aResult);
|
|
|
|
static nsresult GetDefaultLocalizedString(const char* aPref,
|
|
|
|
nsAString* aResult);
|
|
|
|
|
|
|
|
static nsresult GetDefaultComplex(const char* aPref, const nsIID &aType,
|
|
|
|
void** aResult);
|
|
|
|
|
2012-04-04 08:06:27 +04:00
|
|
|
/**
|
|
|
|
* Gets the type of the pref.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t GetDefaultType(const char* aPref);
|
2012-04-04 08:06:27 +04:00
|
|
|
|
2011-11-02 18:51:39 +04:00
|
|
|
// Used to synchronise preferences between chrome and content processes.
|
2012-08-23 00:00:21 +04:00
|
|
|
static void GetPreferences(InfallibleTArray<PrefSetting>* aPrefs);
|
|
|
|
static void GetPreference(PrefSetting* aPref);
|
|
|
|
static void SetPreference(const PrefSetting& aPref);
|
2011-11-02 18:51:39 +04:00
|
|
|
|
2013-01-18 04:45:11 +04:00
|
|
|
static int64_t SizeOfIncludingThisAndOtherStuff(mozilla::MallocSizeOf aMallocSizeOf);
|
2012-10-11 19:36:21 +04:00
|
|
|
|
2001-03-23 02:34:41 +03:00
|
|
|
protected:
|
2014-07-01 02:11:48 +04:00
|
|
|
virtual ~Preferences();
|
|
|
|
|
2002-04-16 22:48:19 +04:00
|
|
|
nsresult NotifyServiceObservers(const char *aSubject);
|
2012-03-23 05:13:20 +04:00
|
|
|
/**
|
|
|
|
* Reads the default pref file or, if that failed, try to save a new one.
|
|
|
|
*
|
|
|
|
* @return NS_OK if either action succeeded,
|
|
|
|
* or the error code related to the read attempt.
|
|
|
|
*/
|
2002-04-16 22:48:19 +04:00
|
|
|
nsresult UseDefaultPrefFile();
|
|
|
|
nsresult UseUserPrefFile();
|
2003-05-02 08:00:19 +04:00
|
|
|
nsresult ReadAndOwnUserPrefFile(nsIFile *aFile);
|
|
|
|
nsresult ReadAndOwnSharedUserPrefFile(nsIFile *aFile);
|
|
|
|
nsresult SavePrefFileInternal(nsIFile* aFile);
|
2002-04-16 22:48:19 +04:00
|
|
|
nsresult WritePrefFile(nsIFile* aFile);
|
2006-11-28 17:11:40 +03:00
|
|
|
nsresult MakeBackupPrefFile(nsIFile *aFile);
|
2001-03-23 02:34:41 +03:00
|
|
|
|
|
|
|
private:
|
2009-11-03 22:05:31 +03:00
|
|
|
nsCOMPtr<nsIFile> mCurrentFile;
|
2011-05-23 18:54:03 +04:00
|
|
|
|
|
|
|
static Preferences* sPreferences;
|
2012-01-16 12:47:13 +04:00
|
|
|
static nsIPrefBranch* sRootBranch;
|
2011-06-22 10:39:10 +04:00
|
|
|
static nsIPrefBranch* sDefaultRootBranch;
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool sShutdown;
|
2011-05-23 18:54:03 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Init static members. TRUE if it succeeded. Otherwise, FALSE.
|
|
|
|
*/
|
2011-11-06 23:27:56 +04:00
|
|
|
static bool InitStaticMembers();
|
2001-03-23 02:34:41 +03:00
|
|
|
};
|
|
|
|
|
2011-05-23 18:54:02 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
#endif // mozilla_Preferences_h
|