Bug 1105827 - Part 1: Add stub PermissionStatus implementation. r=baku

This commit is contained in:
Birunthan Mohanathas 2015-07-28 06:33:46 -07:00
parent b3b4eca437
commit 89209dc5c7
7 changed files with 114 additions and 0 deletions

View File

@ -0,0 +1,33 @@
/* -*- 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 "mozilla/dom/PermissionStatus.h"
#include "mozilla/Services.h"
#include "nsIPermissionManager.h"
namespace mozilla {
namespace dom {
PermissionStatus::PermissionStatus(nsPIDOMWindow* aWindow,
PermissionState aState)
: DOMEventTargetHelper(aWindow)
, mState(aState)
{
}
PermissionStatus::~PermissionStatus()
{
}
JSObject*
PermissionStatus::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return PermissionStatusBinding::Wrap(aCx, this, aGivenProto);
}
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,38 @@
/* -*- 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_PermissionStatus_h_
#define mozilla_dom_PermissionStatus_h_
#include "mozilla/dom/PermissionStatusBinding.h"
#include "mozilla/DOMEventTargetHelper.h"
namespace mozilla {
namespace dom {
class PermissionStatus final
: public DOMEventTargetHelper
{
public:
explicit PermissionStatus(nsPIDOMWindow* aWindow, PermissionState aState);
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
PermissionState State() const { return mState; }
IMPL_EVENT_HANDLER(change)
private:
~PermissionStatus();
PermissionState mState;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_permissionstatus_h_

View File

@ -4,6 +4,14 @@
# 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/.
EXPORTS.mozilla.dom += [
'PermissionStatus.h',
]
UNIFIED_SOURCES += [
'PermissionStatus.cpp',
]
EXTRA_COMPONENTS += [
'PermissionPromptService.js',
'PermissionPromptService.manifest',
@ -33,3 +41,7 @@ if CONFIG['MOZ_WEBSMS_BACKEND']:
if CONFIG['MOZ_TIME_MANAGER']:
MOCHITEST_MANIFESTS += ['tests/mochitest-time.ini']
FAIL_ON_WARNINGS = True
FINAL_LIBRARY = 'xul'

View File

@ -893,6 +893,8 @@ var interfaceNamesInGlobalScope =
"PeriodicWave",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "PermissionSettings", b2g: true, permission: ["permissions"]},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "PermissionStatus", nightly: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "PhoneNumberService", permission: ["phonenumberservice"]},
// IMPORTANT: Do not change this list without review from a DOM peer!

View File

@ -0,0 +1,21 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* https://w3c.github.io/permissions/#status-of-a-permission
*/
enum PermissionState {
"granted",
"denied",
"prompt"
};
[Exposed=(Window),
Pref="dom.permissions.enabled"]
interface PermissionStatus : EventTarget {
readonly attribute PermissionState state;
attribute EventHandler onchange;
};

View File

@ -355,6 +355,7 @@ WEBIDL_FILES = [
'PerformanceTiming.webidl',
'PeriodicWave.webidl',
'PermissionSettings.webidl',
'PermissionStatus.webidl',
'PhoneNumberService.webidl',
'Plugin.webidl',
'PluginArray.webidl',

View File

@ -124,6 +124,13 @@ pref("dom.indexedDB.logging.details", true);
// Enable profiler marks for indexedDB events.
pref("dom.indexedDB.logging.profiler-marks", false);
// Whether or not the Permissions API is enabled.
#ifdef NIGHTLY_BUILD
pref("dom.permissions.enabled", true);
#else
pref("dom.permissions.enabled", false);
#endif
// Whether or not Web Workers are enabled.
pref("dom.workers.enabled", true);
// The number of workers per domain allowed to run concurrently.