зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1105827 - Part 6: Add PermissionUtils.h for helper functions. r=baku
This commit is contained in:
Родитель
6e88e10459
Коммит
a1f31ea066
|
@ -0,0 +1,29 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* 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/. */
|
||||||
|
|
||||||
|
#include "PermissionUtils.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
PermissionState
|
||||||
|
ActionToPermissionState(uint32_t aAction)
|
||||||
|
{
|
||||||
|
switch (aAction) {
|
||||||
|
case nsIPermissionManager::ALLOW_ACTION:
|
||||||
|
return PermissionState::Granted;
|
||||||
|
|
||||||
|
case nsIPermissionManager::DENY_ACTION:
|
||||||
|
return PermissionState::Denied;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case nsIPermissionManager::PROMPT_ACTION:
|
||||||
|
return PermissionState::Prompt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* 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_dom_PermissionUtils_h_
|
||||||
|
#define mozilla_dom_PermissionUtils_h_
|
||||||
|
|
||||||
|
#include "mozilla/dom/PermissionsBinding.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
PermissionState ActionToPermissionState(uint32_t aAction);
|
||||||
|
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif
|
|
@ -9,8 +9,8 @@
|
||||||
#include "mozilla/dom/PermissionsBinding.h"
|
#include "mozilla/dom/PermissionsBinding.h"
|
||||||
#include "mozilla/dom/Promise.h"
|
#include "mozilla/dom/Promise.h"
|
||||||
#include "mozilla/Services.h"
|
#include "mozilla/Services.h"
|
||||||
|
|
||||||
#include "nsIPermissionManager.h"
|
#include "nsIPermissionManager.h"
|
||||||
|
#include "PermissionUtils.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
@ -42,22 +42,6 @@ Permissions::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
PermissionState
|
|
||||||
ActionToPermissionState(uint32_t aAction)
|
|
||||||
{
|
|
||||||
switch (aAction) {
|
|
||||||
case nsIPermissionManager::ALLOW_ACTION:
|
|
||||||
return PermissionState::Granted;
|
|
||||||
|
|
||||||
case nsIPermissionManager::DENY_ACTION:
|
|
||||||
return PermissionState::Denied;
|
|
||||||
|
|
||||||
default:
|
|
||||||
case nsIPermissionManager::PROMPT_ACTION:
|
|
||||||
return PermissionState::Prompt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
CheckPermission(const char* aName,
|
CheckPermission(const char* aName,
|
||||||
nsPIDOMWindow* aWindow,
|
nsPIDOMWindow* aWindow,
|
||||||
|
|
|
@ -12,6 +12,7 @@ EXPORTS.mozilla.dom += [
|
||||||
UNIFIED_SOURCES += [
|
UNIFIED_SOURCES += [
|
||||||
'Permissions.cpp',
|
'Permissions.cpp',
|
||||||
'PermissionStatus.cpp',
|
'PermissionStatus.cpp',
|
||||||
|
'PermissionUtils.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
EXTRA_COMPONENTS += [
|
EXTRA_COMPONENTS += [
|
||||||
|
|
Загрузка…
Ссылка в новой задаче