This source file includes following definitions.
- AllPermissions
- GetForCommandLine
- HasPermission
#include "ppapi/shared_impl/ppapi_permissions.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "ppapi/shared_impl/ppapi_switches.h"
namespace ppapi {
PpapiPermissions::PpapiPermissions() : permissions_(0) {}
PpapiPermissions::PpapiPermissions(uint32 perms) : permissions_(perms) {}
PpapiPermissions::~PpapiPermissions() {}
PpapiPermissions PpapiPermissions::AllPermissions() {
return PpapiPermissions(PERMISSION_ALL_BITS);
}
PpapiPermissions PpapiPermissions::GetForCommandLine(uint32 base_perms) {
uint32 additional_permissions = 0;
#if !defined(OS_NACL)
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnablePepperTesting))
additional_permissions |= ppapi::PERMISSION_ALL_BITS;
#endif
return PpapiPermissions(base_perms | additional_permissions);
}
bool PpapiPermissions::HasPermission(Permission perm) const {
uint32 perm_int = static_cast<uint32>(perm);
if (!perm_int)
return true;
DCHECK((perm_int & (perm_int - 1)) == 0);
return !!(permissions_ & perm_int);
}
}