Bug 1105827 - Part 6: Add PermissionUtils.h for helper functions. r=baku

This commit is contained in:
Birunthan Mohanathas 2015-07-31 15:49:55 -07:00
Родитель 6e88e10459
Коммит a1f31ea066
4 изменённых файлов: 51 добавлений и 17 удалений

Просмотреть файл

@ -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/Promise.h"
#include "mozilla/Services.h"
#include "nsIPermissionManager.h"
#include "PermissionUtils.h"
namespace mozilla {
namespace dom {
@ -42,22 +42,6 @@ Permissions::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
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
CheckPermission(const char* aName,
nsPIDOMWindow* aWindow,

Просмотреть файл

@ -12,6 +12,7 @@ EXPORTS.mozilla.dom += [
UNIFIED_SOURCES += [
'Permissions.cpp',
'PermissionStatus.cpp',
'PermissionUtils.cpp',
]
EXTRA_COMPONENTS += [