Bug 861496 - Replace #ifdef MOZ_SYS_MSG by a preference. r=fabrice

This commit is contained in:
Kevin Grandon 2013-04-30 09:01:46 -04:00
parent 453aaf5aa1
commit 076af09c6f
9 changed files with 57 additions and 62 deletions

View File

@ -519,6 +519,8 @@ pref("ui.click_hold_context_menus.delay", 750);
// Enable device storage
pref("device.storage.enabled", true);
// Enable system message
pref("dom.sysmsg.enabled", true);
pref("media.plugins.enabled", false);
pref("media.omx.enabled", true);

View File

@ -47,7 +47,6 @@ MOZ_MEDIA_NAVIGATOR=1
MOZ_APP_ID={3c2e2abc-06d4-11e1-ac3b-374f68613e61}
MOZ_EXTENSION_MANAGER=1
MOZ_SYS_MSG=1
MOZ_TIME_MANAGER=1
MOZ_B2G_CERTDATA=1

View File

@ -4263,7 +4263,6 @@ MOZ_WEBSMS_BACKEND=
MOZ_ANDROID_WALLPAPER=
MOZ_ANDROID_BEAM=
ACCESSIBILITY=1
MOZ_SYS_MSG=
MOZ_TIME_MANAGER=
MOZ_PAY=
MOZ_AUDIO_CHANNEL_MANAGER=
@ -7642,14 +7641,6 @@ if test -n "$MOZ_B2G_BT"; then
fi
AC_SUBST(MOZ_B2G_BT)
dnl ========================================================
dnl = Enable Support for System Messages API
dnl ========================================================
if test -n "$MOZ_SYS_MSG"; then
AC_DEFINE(MOZ_SYS_MSG)
fi
AC_SUBST(MOZ_SYS_MSG)
dnl ========================================================
dnl = Enable Support for Time Manager API
dnl ========================================================

View File

@ -8,6 +8,7 @@
#include "DOMRequest.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "nsIActivityProxy.h"
#include "mozilla/Preferences.h"
#define NS_DOMACTIVITY_CID \
{0x1c5b0930, 0xc90c, 0x4e9c, {0xaf, 0x4e, 0xb0, 0xb7, 0xa6, 0x59, 0xb4, 0xed}}
@ -28,11 +29,7 @@ public:
static bool PrefEnabled()
{
#ifdef MOZ_SYS_MSG
return true;
#else
return false;
#endif
return Preferences::GetBool("dom.sysmsg.enabled", false);
}
static already_AddRefed<Activity>

View File

@ -25,6 +25,14 @@ function debug(aMsg) {
//dump("-*-*- Webapps.jsm : " + aMsg + "\n");
}
let cachedSysMsgPref = null;
function supportSystemMessages() {
if (cachedSysMsgPref === null) {
cachedSysMsgPref = Services.prefs.getBoolPref("dom.sysmsg.enabled");
}
return cachedSysMsgPref;
}
// Minimum delay between two progress events while downloading, in ms.
const MIN_PROGRESS_EVENT_DELAY = 1000;
@ -180,21 +188,21 @@ this.DOMApplicationRegistry = {
for (let id in this.webapps) {
ids.push({ id: id });
}
#ifdef MOZ_SYS_MSG
this._processManifestForIds(ids, aRunUpdate);
#else
// Read the CSPs. If MOZ_SYS_MSG is defined this is done on
// _processManifestForIds so as to not reading the manifests
// twice
this._readManifests(ids, (function readCSPs(aResults) {
aResults.forEach(function registerManifest(aResult) {
this.webapps[aResult.id].csp = aResult.manifest.csp || "";
}, this);
}).bind(this));
if (supportSystemMessages()) {
this._processManifestForIds(ids, aRunUpdate);
} else {
// Read the CSPs. If MOZ_SYS_MSG is defined this is done on
// _processManifestForIds so as to not reading the manifests
// twice
this._readManifests(ids, (function readCSPs(aResults) {
aResults.forEach(function registerManifest(aResult) {
this.webapps[aResult.id].csp = aResult.manifest.csp || "";
}, this);
}).bind(this));
// Nothing else to do but notifying we're ready.
this.notifyAppsRegistryReady();
#endif
// Nothing else to do but notifying we're ready.
this.notifyAppsRegistryReady();
}
},
updatePermissionsForApp: function updatePermissionsForApp(aId) {
@ -439,7 +447,6 @@ this.DOMApplicationRegistry = {
}).bind(this));
},
#ifdef MOZ_SYS_MSG
// |aEntryPoint| is either the entry_point name or the null in which case we
// use the root of the manifest.
_registerSystemMessagesForEntryPoint: function(aManifest, aApp, aEntryPoint) {
@ -657,7 +664,6 @@ this.DOMApplicationRegistry = {
this._registerActivitiesForApps(appsToRegister, aRunUpdate);
}).bind(this));
},
#endif
observe: function(aSubject, aTopic, aData) {
if (aTopic == "xpcom-shutdown") {
@ -1284,16 +1290,17 @@ this.DOMApplicationRegistry = {
updateAppHandlers: function(aOldManifest, aNewManifest, aApp) {
debug("updateAppHandlers: old=" + aOldManifest + " new=" + aNewManifest);
this.notifyAppsRegistryStart();
#ifdef MOZ_SYS_MSG
if (aOldManifest) {
this._unregisterActivities(aOldManifest, aApp);
if (supportSystemMessages()) {
if (aOldManifest) {
this._unregisterActivities(aOldManifest, aApp);
}
this._registerSystemMessages(aNewManifest, aApp);
this._registerActivities(aNewManifest, aApp, true);
} else {
// Nothing else to do but notifying we're ready.
this.notifyAppsRegistryReady();
}
this._registerSystemMessages(aNewManifest, aApp);
this._registerActivities(aNewManifest, aApp, true);
#else
// Nothing else to do but notifying we're ready.
this.notifyAppsRegistryReady();
#endif
},
checkForUpdate: function(aData, aMm) {
@ -2486,11 +2493,11 @@ this.DOMApplicationRegistry = {
let appNote = JSON.stringify(AppsUtils.cloneAppObject(app));
appNote.id = id;
#ifdef MOZ_SYS_MSG
this._readManifests([{ id: id }], (function unregisterManifest(aResult) {
this._unregisterActivities(aResult[0].manifest, app);
}).bind(this));
#endif
if (supportSystemMessages()) {
this._readManifests([{ id: id }], (function unregisterManifest(aResult) {
this._unregisterActivities(aResult[0].manifest, app);
}).bind(this));
}
let dir = this._getAppDir(id);
try {

View File

@ -225,11 +225,9 @@ Navigator::Invalidate()
mCameraManager = nullptr;
#ifdef MOZ_SYS_MSG
if (mMessagesManager) {
mMessagesManager = nullptr;
}
#endif
#ifdef MOZ_AUDIO_CHANNEL_MANAGER
if (mAudioChannelManager) {
@ -1411,7 +1409,6 @@ Navigator::GetMozBluetooth(nsIDOMBluetoothManager** aBluetooth)
//*****************************************************************************
// nsNavigator::nsIDOMNavigatorSystemMessages
//*****************************************************************************
#ifdef MOZ_SYS_MSG
nsresult
Navigator::EnsureMessagesManager()
{
@ -1439,34 +1436,33 @@ Navigator::EnsureMessagesManager()
return NS_OK;
}
#endif
NS_IMETHODIMP
Navigator::MozHasPendingMessage(const nsAString& aType, bool *aResult)
{
#ifdef MOZ_SYS_MSG
if (!Preferences::GetBool("dom.sysmsg.enabled", false)) {
return NS_ERROR_NOT_IMPLEMENTED;
}
*aResult = false;
nsresult rv = EnsureMessagesManager();
NS_ENSURE_SUCCESS(rv, rv);
return mMessagesManager->MozHasPendingMessage(aType, aResult);
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
NS_IMETHODIMP
Navigator::MozSetMessageHandler(const nsAString& aType,
nsIDOMSystemMessageCallback *aCallback)
{
#ifdef MOZ_SYS_MSG
if (!Preferences::GetBool("dom.sysmsg.enabled", false)) {
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult rv = EnsureMessagesManager();
NS_ENSURE_SUCCESS(rv, rv);
return mMessagesManager->MozSetMessageHandler(aType, aCallback);
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
//*****************************************************************************

View File

@ -186,10 +186,9 @@ public:
*/
void OnNavigation();
#ifdef MOZ_SYS_MSG
// Helper to initialize mMessagesManager.
nsresult EnsureMessagesManager();
#endif
NS_DECL_NSIDOMNAVIGATORCAMERA
private:

View File

@ -280,6 +280,8 @@ using mozilla::dom::workers::ResolveWorkerClasses;
#include "nsIDOMMediaQueryList.h"
#include "mozilla/dom/Activity.h"
#include "nsDOMTouchEvent.h"
#include "nsWrapperCacheInlines.h"
@ -1655,9 +1657,8 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorBluetooth)
#endif
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorCamera)
#ifdef MOZ_SYS_MSG
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorSystemMessages)
#endif
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMNavigatorSystemMessages,
Activity::PrefEnabled())
#ifdef MOZ_TIME_MANAGER
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozNavigatorTime)
#endif

View File

@ -751,6 +751,9 @@ pref("dom.experimental_forms", false);
// Don't enable <input type=range> yet:
pref("dom.experimental_forms_range", true);
// Enables system messages and activities
pref("dom.sysmsg.enabled", false);
// Allocation Threshold for Workers
pref("dom.workers.mem.gc_allocation_threshold_mb", 30);