1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/modules/libpref/src/nsPrefsFactory.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "mozilla/ModuleUtils.h" 1.10 +#include "mozilla/Preferences.h" 1.11 +#include "nsPrefBranch.h" 1.12 +#include "prefapi.h" 1.13 + 1.14 +using namespace mozilla; 1.15 + 1.16 +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(Preferences, 1.17 + Preferences::GetInstanceForService) 1.18 +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefLocalizedString, Init) 1.19 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsRelativeFilePref) 1.20 + 1.21 +static NS_DEFINE_CID(kPrefServiceCID, NS_PREFSERVICE_CID); 1.22 +static NS_DEFINE_CID(kPrefLocalizedStringCID, NS_PREFLOCALIZEDSTRING_CID); 1.23 +static NS_DEFINE_CID(kRelativeFilePrefCID, NS_RELATIVEFILEPREF_CID); 1.24 + 1.25 +static mozilla::Module::CIDEntry kPrefCIDs[] = { 1.26 + { &kPrefServiceCID, true, nullptr, PreferencesConstructor }, 1.27 + { &kPrefLocalizedStringCID, false, nullptr, nsPrefLocalizedStringConstructor }, 1.28 + { &kRelativeFilePrefCID, false, nullptr, nsRelativeFilePrefConstructor }, 1.29 + { nullptr } 1.30 +}; 1.31 + 1.32 +static mozilla::Module::ContractIDEntry kPrefContracts[] = { 1.33 + { NS_PREFSERVICE_CONTRACTID, &kPrefServiceCID }, 1.34 + { NS_PREFLOCALIZEDSTRING_CONTRACTID, &kPrefLocalizedStringCID }, 1.35 + { NS_RELATIVEFILEPREF_CONTRACTID, &kRelativeFilePrefCID }, 1.36 + // compatibility for extension that uses old service 1.37 + { "@mozilla.org/preferences;1", &kPrefServiceCID }, 1.38 + { nullptr } 1.39 +}; 1.40 + 1.41 +static void 1.42 +UnloadPrefsModule() 1.43 +{ 1.44 + Preferences::Shutdown(); 1.45 +} 1.46 + 1.47 +static const mozilla::Module kPrefModule = { 1.48 + mozilla::Module::kVersion, 1.49 + kPrefCIDs, 1.50 + kPrefContracts, 1.51 + nullptr, 1.52 + nullptr, 1.53 + nullptr, 1.54 + UnloadPrefsModule 1.55 +}; 1.56 + 1.57 +NSMODULE_DEFN(nsPrefModule) = &kPrefModule;