mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Backed out changeset 92d2843b5938 (bug 1105827)
This commit is contained in:
parent
02595ce842
commit
e0592c3416
@ -9,39 +9,6 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
const char* kPermissionTypes[] = {
|
||||
"geo",
|
||||
"desktop-notification",
|
||||
"push",
|
||||
"midi"
|
||||
};
|
||||
|
||||
// `-1` for the last null entry.
|
||||
const size_t kPermissionNameCount =
|
||||
ArrayLength(PermissionNameValues::strings) - 1;
|
||||
|
||||
static_assert(ArrayLength(kPermissionTypes) == kPermissionNameCount,
|
||||
"kPermissionTypes and PermissionName count should match");
|
||||
|
||||
const char*
|
||||
PermissionNameToType(PermissionName aName)
|
||||
{
|
||||
MOZ_ASSERT((size_t)aName < ArrayLength(kPermissionTypes));
|
||||
return kPermissionTypes[static_cast<size_t>(aName)];
|
||||
}
|
||||
|
||||
Maybe<PermissionName>
|
||||
TypeToPermissionName(const char* aType)
|
||||
{
|
||||
for (size_t i = 0; i < ArrayLength(kPermissionTypes); ++i) {
|
||||
if (!strcmp(aType, kPermissionTypes[i])) {
|
||||
return Some(static_cast<PermissionName>(i));
|
||||
}
|
||||
}
|
||||
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
PermissionState
|
||||
ActionToPermissionState(uint32_t aAction)
|
||||
{
|
||||
|
@ -8,15 +8,10 @@
|
||||
#define mozilla_dom_PermissionUtils_h_
|
||||
|
||||
#include "mozilla/dom/PermissionsBinding.h"
|
||||
#include "mozilla/dom/PermissionStatusBinding.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
const char* PermissionNameToType(PermissionName aName);
|
||||
Maybe<PermissionName> TypeToPermissionName(const char* aType);
|
||||
|
||||
PermissionState ActionToPermissionState(uint32_t aAction);
|
||||
|
||||
} // namespace dom
|
||||
|
@ -43,10 +43,11 @@ Permissions::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
namespace {
|
||||
|
||||
nsresult
|
||||
CheckPermission(PermissionName aName,
|
||||
CheckPermission(const char* aName,
|
||||
nsPIDOMWindow* aWindow,
|
||||
PermissionState& aResult)
|
||||
{
|
||||
MOZ_ASSERT(aName);
|
||||
MOZ_ASSERT(aWindow);
|
||||
|
||||
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
|
||||
@ -55,9 +56,7 @@ CheckPermission(PermissionName aName,
|
||||
}
|
||||
|
||||
uint32_t action = nsIPermissionManager::DENY_ACTION;
|
||||
nsresult rv = permMgr->TestPermissionFromWindow(aWindow,
|
||||
PermissionNameToType(aName),
|
||||
&action);
|
||||
nsresult rv = permMgr->TestPermissionFromWindow(aWindow, aName, &action);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -82,7 +81,7 @@ CheckPushPermission(JSContext* aCx,
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return CheckPermission(permission.mName, aWindow, aResult);
|
||||
return CheckPermission("push", aWindow, aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -99,8 +98,10 @@ CheckPermission(JSContext* aCx,
|
||||
|
||||
switch (permission.mName) {
|
||||
case PermissionName::Geolocation:
|
||||
return CheckPermission("geo", aWindow, aResult);
|
||||
|
||||
case PermissionName::Notifications:
|
||||
return CheckPermission(permission.mName, aWindow, aResult);
|
||||
return CheckPermission("desktop-notification", aWindow, aResult);
|
||||
|
||||
case PermissionName::Push:
|
||||
return CheckPushPermission(aCx, aPermission, aWindow, aResult);
|
||||
|
Loading…
Reference in New Issue
Block a user