diff --git a/dom/permission/PermissionUtils.cpp b/dom/permission/PermissionUtils.cpp new file mode 100644 index 000000000000..70a478b4305d --- /dev/null +++ b/dom/permission/PermissionUtils.cpp @@ -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 diff --git a/dom/permission/PermissionUtils.h b/dom/permission/PermissionUtils.h new file mode 100644 index 000000000000..ebf6a43c435b --- /dev/null +++ b/dom/permission/PermissionUtils.h @@ -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 diff --git a/dom/permission/Permissions.cpp b/dom/permission/Permissions.cpp index c7518f9983f2..36e046dd587e 100644 --- a/dom/permission/Permissions.cpp +++ b/dom/permission/Permissions.cpp @@ -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 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, diff --git a/dom/permission/moz.build b/dom/permission/moz.build index b027459d55f2..34e599b2efd0 100644 --- a/dom/permission/moz.build +++ b/dom/permission/moz.build @@ -12,6 +12,7 @@ EXPORTS.mozilla.dom += [ UNIFIED_SOURCES += [ 'Permissions.cpp', 'PermissionStatus.cpp', + 'PermissionUtils.cpp', ] EXTRA_COMPONENTS += [