nsPrefsFactory.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "mozilla/ModuleUtils.h"
  6. #include "mozilla/Preferences.h"
  7. #include "nsPrefBranch.h"
  8. #include "prefapi.h"
  9. using namespace mozilla;
  10. NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(Preferences,
  11. Preferences::GetInstanceForService)
  12. NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefLocalizedString, Init)
  13. NS_GENERIC_FACTORY_CONSTRUCTOR(nsRelativeFilePref)
  14. static NS_DEFINE_CID(kPrefServiceCID, NS_PREFSERVICE_CID);
  15. static NS_DEFINE_CID(kPrefLocalizedStringCID, NS_PREFLOCALIZEDSTRING_CID);
  16. static NS_DEFINE_CID(kRelativeFilePrefCID, NS_RELATIVEFILEPREF_CID);
  17. static mozilla::Module::CIDEntry kPrefCIDs[] = {
  18. { &kPrefServiceCID, true, nullptr, PreferencesConstructor },
  19. { &kPrefLocalizedStringCID, false, nullptr, nsPrefLocalizedStringConstructor },
  20. { &kRelativeFilePrefCID, false, nullptr, nsRelativeFilePrefConstructor },
  21. { nullptr }
  22. };
  23. static mozilla::Module::ContractIDEntry kPrefContracts[] = {
  24. { NS_PREFSERVICE_CONTRACTID, &kPrefServiceCID },
  25. { NS_PREFLOCALIZEDSTRING_CONTRACTID, &kPrefLocalizedStringCID },
  26. { NS_RELATIVEFILEPREF_CONTRACTID, &kRelativeFilePrefCID },
  27. // compatibility for extension that uses old service
  28. { "@mozilla.org/preferences;1", &kPrefServiceCID },
  29. { nullptr }
  30. };
  31. static void
  32. UnloadPrefsModule()
  33. {
  34. Preferences::Shutdown();
  35. }
  36. static const mozilla::Module kPrefModule = {
  37. mozilla::Module::kVersion,
  38. kPrefCIDs,
  39. kPrefContracts,
  40. nullptr,
  41. nullptr,
  42. nullptr,
  43. UnloadPrefsModule
  44. };
  45. NSMODULE_DEFN(nsPrefModule) = &kPrefModule;