Bug 782460: Fix hal enum serializers, make wake lock permission checking match the DOM's, and log a message when an app process fails a backstop permission check. r=gal

This commit is contained in:
Chris Jones 2012-08-25 15:38:04 -07:00
parent e98a5d9b7e
commit dafc895290
3 changed files with 15 additions and 13 deletions

View File

@ -36,8 +36,11 @@ AppProcessHasPermission(PBrowserParent* aActor, const char* aPermission)
}
bool hasPermission = false;
return (NS_SUCCEEDED(app->HasPermission(aPermission, &hasPermission)) &&
hasPermission);
if (!NS_SUCCEEDED(app->HasPermission(aPermission, &hasPermission)) ||
!hasPermission) {
printf_stderr("Security problem: App process does not have `%s' permission. It will be killed.", aPermission);
}
return hasPermission;
}
bool

View File

@ -29,12 +29,14 @@ enum LightType {
};
enum LightMode {
eHalLightMode_User = 0, // brightness is managed by user setting
eHalLightMode_Sensor = 1 // brightness is managed by a light sensor
eHalLightMode_Sensor = 1, // brightness is managed by a light sensor
eHalLightMode_Count
};
enum FlashMode {
eHalLightFlash_None = 0,
eHalLightFlash_Timed = 1, // timed flashing. Use flashOnMS and flashOffMS for timing
eHalLightFlash_Hardware = 2 // hardware assisted flashing
eHalLightFlash_Hardware = 2, // hardware assisted flashing
eHalLightFlash_Count
};
class SwitchEvent;
@ -69,6 +71,7 @@ enum WakeLockControl {
WAKE_LOCK_REMOVE_ONE = -1,
WAKE_LOCK_NO_CHANGE = 0,
WAKE_LOCK_ADD_ONE = 1,
NUM_WAKE_LOCK
};
} // namespace hal
@ -93,7 +96,7 @@ template <>
struct ParamTraits<mozilla::hal::LightMode>
: public EnumSerializer<mozilla::hal::LightMode,
mozilla::hal::eHalLightMode_User,
mozilla::hal::eHalLightMode_Sensor>
mozilla::hal::eHalLightMode_Count>
{};
/**
@ -103,7 +106,7 @@ template <>
struct ParamTraits<mozilla::hal::FlashMode>
: public EnumSerializer<mozilla::hal::FlashMode,
mozilla::hal::eHalLightFlash_None,
mozilla::hal::eHalLightFlash_Hardware>
mozilla::hal::eHalLightFlash_Count>
{};
/**
@ -113,7 +116,7 @@ template <>
struct ParamTraits<mozilla::hal::WakeLockControl>
: public EnumSerializer<mozilla::hal::WakeLockControl,
mozilla::hal::WAKE_LOCK_REMOVE_ONE,
mozilla::hal::WAKE_LOCK_ADD_ONE>
mozilla::hal::NUM_WAKE_LOCK>
{};
/**

View File

@ -574,9 +574,7 @@ public:
const WakeLockControl &aLockAdjust,
const WakeLockControl &aHiddenAdjust) MOZ_OVERRIDE
{
if (!AppProcessHasPermission(this, "power")) {
return false;
}
// We allow arbitrary content to use wake locks.
hal::ModifyWakeLock(aTopic, aLockAdjust, aHiddenAdjust);
return true;
}
@ -584,9 +582,7 @@ public:
virtual bool
RecvEnableWakeLockNotifications() MOZ_OVERRIDE
{
if (!AppProcessHasPermission(this, "power")) {
return false;
}
// We allow arbitrary content to use wake locks.
hal::RegisterWakeLockObserver(this);
return true;
}