mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-19 17:38:36 +00:00
Bug 793479: Update C++ permission-checking API to match that of the message-manager one. r=jlebar
This commit is contained in:
parent
5baa27268e
commit
b7f90c6b8c
@ -19,7 +19,7 @@ using namespace mozilla::services;
|
||||
namespace mozilla {
|
||||
|
||||
bool
|
||||
AppProcessHasPermission(PBrowserParent* aActor, const char* aPermission)
|
||||
AssertAppProcessPermission(PBrowserParent* aActor, const char* aPermission)
|
||||
{
|
||||
if (!aActor) {
|
||||
NS_WARNING("Testing permissions for null actor");
|
||||
@ -46,12 +46,12 @@ AppProcessHasPermission(PBrowserParent* aActor, const char* aPermission)
|
||||
}
|
||||
|
||||
bool
|
||||
AppProcessHasPermission(PContentParent* aActor, const char* aPermission)
|
||||
AssertAppProcessPermission(PContentParent* aActor, const char* aPermission)
|
||||
{
|
||||
const InfallibleTArray<PBrowserParent*>& browsers =
|
||||
aActor->ManagedPBrowserParent();
|
||||
for (uint32_t i = 0; i < browsers.Length(); ++i) {
|
||||
if (AppProcessHasPermission(browsers[i], aPermission)) {
|
||||
if (AssertAppProcessPermission(browsers[i], aPermission)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -59,9 +59,9 @@ AppProcessHasPermission(PContentParent* aActor, const char* aPermission)
|
||||
}
|
||||
|
||||
bool
|
||||
AppProcessHasPermission(PHalParent* aActor, const char* aPermission)
|
||||
AssertAppProcessPermission(PHalParent* aActor, const char* aPermission)
|
||||
{
|
||||
return AppProcessHasPermission(aActor->Manager(), aPermission);
|
||||
return AssertAppProcessPermission(aActor->Manager(), aPermission);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -5,8 +5,8 @@
|
||||
* 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/. */
|
||||
|
||||
#ifndef mozilla_Capabilities_h
|
||||
#define mozilla_Capabilities_h
|
||||
#ifndef mozilla_AppProcessPermissions_h
|
||||
#define mozilla_AppProcessPermissions_h
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -21,31 +21,34 @@ class PHalParent;
|
||||
|
||||
/**
|
||||
* Return true iff the specified browser has the specified capability.
|
||||
* If this returns false, the browser didn't have the permission and
|
||||
* will be killed.
|
||||
*/
|
||||
bool
|
||||
AppProcessHasPermissions(mozilla::dom::PBrowserParent* aActor,
|
||||
const char* aPermission);
|
||||
AssertAppProcessPermission(mozilla::dom::PBrowserParent* aActor,
|
||||
const char* aPermission);
|
||||
|
||||
/**
|
||||
* Return true iff any of the PBrowsers loaded in this content process
|
||||
* has the specified capability.
|
||||
* has the specified capability. If this returns false, the process
|
||||
* didn't have the permission and will be killed.
|
||||
*/
|
||||
bool
|
||||
AppProcessHasPermission(mozilla::dom::PContentParent* aActor,
|
||||
const char* aPermission);
|
||||
AssertAppProcessPermission(mozilla::dom::PContentParent* aActor,
|
||||
const char* aPermission);
|
||||
|
||||
bool
|
||||
AppProcessHasPermission(mozilla::hal_sandbox::PHalParent* aActor,
|
||||
const char* aPermission);
|
||||
AssertAppProcessPermission(mozilla::hal_sandbox::PHalParent* aActor,
|
||||
const char* aPermission);
|
||||
|
||||
// NB: when adding capability checks for other IPDL actors, please add
|
||||
// them to this file and have them delegate to the two functions above
|
||||
// as appropriate. For example,
|
||||
//
|
||||
// bool AppProcessHasCapability(PNeckoParent* aActor) {
|
||||
// return AppProcessHasCapability(aActor->Manager());
|
||||
// return AssertAppProcessPermission(aActor->Manager());
|
||||
// }
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_Capabilities_h
|
||||
#endif // mozilla_AppProcessPermissions_h
|
||||
|
@ -1450,7 +1450,7 @@ ContentParent::DeallocPExternalHelperApp(PExternalHelperAppParent* aService)
|
||||
PSmsParent*
|
||||
ContentParent::AllocPSms()
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "sms")) {
|
||||
if (!AssertAppProcessPermission(this, "sms")) {
|
||||
return nullptr;
|
||||
}
|
||||
return new SmsParent();
|
||||
@ -1480,7 +1480,7 @@ PBluetoothParent*
|
||||
ContentParent::AllocPBluetooth()
|
||||
{
|
||||
#ifdef MOZ_B2G_BT
|
||||
if (!AppProcessHasPermission(this, "bluetooth")) {
|
||||
if (!AssertAppProcessPermission(this, "bluetooth")) {
|
||||
return nullptr;
|
||||
}
|
||||
return new mozilla::dom::bluetooth::BluetoothParent();
|
||||
|
@ -510,7 +510,7 @@ public:
|
||||
virtual bool
|
||||
RecvGetScreenEnabled(bool *enabled) MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "power")) {
|
||||
if (!AssertAppProcessPermission(this, "power")) {
|
||||
return false;
|
||||
}
|
||||
*enabled = hal::GetScreenEnabled();
|
||||
@ -520,7 +520,7 @@ public:
|
||||
virtual bool
|
||||
RecvSetScreenEnabled(const bool &enabled) MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "power")) {
|
||||
if (!AssertAppProcessPermission(this, "power")) {
|
||||
return false;
|
||||
}
|
||||
hal::SetScreenEnabled(enabled);
|
||||
@ -530,7 +530,7 @@ public:
|
||||
virtual bool
|
||||
RecvGetCpuSleepAllowed(bool *allowed) MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "power")) {
|
||||
if (!AssertAppProcessPermission(this, "power")) {
|
||||
return false;
|
||||
}
|
||||
*allowed = hal::GetCpuSleepAllowed();
|
||||
@ -540,7 +540,7 @@ public:
|
||||
virtual bool
|
||||
RecvSetCpuSleepAllowed(const bool &allowed) MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "power")) {
|
||||
if (!AssertAppProcessPermission(this, "power")) {
|
||||
return false;
|
||||
}
|
||||
hal::SetCpuSleepAllowed(allowed);
|
||||
@ -550,7 +550,7 @@ public:
|
||||
virtual bool
|
||||
RecvGetScreenBrightness(double *brightness) MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "power")) {
|
||||
if (!AssertAppProcessPermission(this, "power")) {
|
||||
return false;
|
||||
}
|
||||
*brightness = hal::GetScreenBrightness();
|
||||
@ -560,7 +560,7 @@ public:
|
||||
virtual bool
|
||||
RecvSetScreenBrightness(const double &brightness) MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "power")) {
|
||||
if (!AssertAppProcessPermission(this, "power")) {
|
||||
return false;
|
||||
}
|
||||
hal::SetScreenBrightness(brightness);
|
||||
@ -574,7 +574,7 @@ public:
|
||||
// controlled as a unit. Those are set through the power API, and
|
||||
// there's no other way to poke lights currently, so we require
|
||||
// "power" privileges here.
|
||||
if (!AppProcessHasPermission(this, "power")) {
|
||||
if (!AssertAppProcessPermission(this, "power")) {
|
||||
return false;
|
||||
}
|
||||
*status = hal::SetLight(aLight, aConfig);
|
||||
@ -584,7 +584,7 @@ public:
|
||||
virtual bool
|
||||
RecvGetLight(const LightType& aLight, LightConfiguration* aConfig, bool* status) MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "power")) {
|
||||
if (!AssertAppProcessPermission(this, "power")) {
|
||||
return false;
|
||||
}
|
||||
*status = hal::GetLight(aLight, aConfig);
|
||||
@ -594,7 +594,7 @@ public:
|
||||
virtual bool
|
||||
RecvAdjustSystemClock(const int32_t &aDeltaMilliseconds) MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "time")) {
|
||||
if (!AssertAppProcessPermission(this, "time")) {
|
||||
return false;
|
||||
}
|
||||
hal::AdjustSystemClock(aDeltaMilliseconds);
|
||||
@ -604,7 +604,7 @@ public:
|
||||
virtual bool
|
||||
RecvSetTimezone(const nsCString& aTimezoneSpec) MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "time")) {
|
||||
if (!AssertAppProcessPermission(this, "time")) {
|
||||
return false;
|
||||
}
|
||||
hal::SetTimezone(aTimezoneSpec);
|
||||
@ -614,7 +614,7 @@ public:
|
||||
virtual bool
|
||||
RecvGetTimezone(nsCString *aTimezoneSpec) MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "time")) {
|
||||
if (!AssertAppProcessPermission(this, "time")) {
|
||||
return false;
|
||||
}
|
||||
*aTimezoneSpec = hal::GetTimezone();
|
||||
@ -638,7 +638,7 @@ public:
|
||||
virtual bool
|
||||
RecvReboot() MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "power")) {
|
||||
if (!AssertAppProcessPermission(this, "power")) {
|
||||
return false;
|
||||
}
|
||||
hal::Reboot();
|
||||
@ -648,7 +648,7 @@ public:
|
||||
virtual bool
|
||||
RecvPowerOff() MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "power")) {
|
||||
if (!AssertAppProcessPermission(this, "power")) {
|
||||
return false;
|
||||
}
|
||||
hal::PowerOff();
|
||||
@ -701,7 +701,7 @@ public:
|
||||
virtual bool
|
||||
RecvGetWakeLockInfo(const nsString &aTopic, WakeLockInformation *aWakeLockInfo) MOZ_OVERRIDE
|
||||
{
|
||||
if (!AppProcessHasPermission(this, "power")) {
|
||||
if (!AssertAppProcessPermission(this, "power")) {
|
||||
return false;
|
||||
}
|
||||
hal::GetWakeLockInfo(aTopic, aWakeLockInfo);
|
||||
|
Loading…
x
Reference in New Issue
Block a user