2015-07-28 06:33:46 -07:00
|
|
|
/* -*- 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_
|
|
|
|
|
2015-08-21 19:53:29 -07:00
|
|
|
#include "mozilla/dom/PermissionsBinding.h"
|
2015-07-28 06:33:46 -07:00
|
|
|
#include "mozilla/dom/PermissionStatusBinding.h"
|
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-08-21 19:53:29 -07:00
|
|
|
class PermissionObserver;
|
|
|
|
|
2015-07-28 06:33:46 -07:00
|
|
|
class PermissionStatus final
|
|
|
|
: public DOMEventTargetHelper
|
|
|
|
{
|
2015-08-21 19:53:29 -07:00
|
|
|
friend class PermissionObserver;
|
|
|
|
|
2015-07-28 06:33:46 -07:00
|
|
|
public:
|
2016-01-30 09:05:36 -08:00
|
|
|
static already_AddRefed<PermissionStatus> Create(nsPIDOMWindowInner* aWindow,
|
2015-07-31 14:56:59 -07:00
|
|
|
PermissionName aName,
|
|
|
|
ErrorResult& aRv);
|
2015-07-28 06:33:46 -07:00
|
|
|
|
|
|
|
JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
|
|
|
PermissionState State() const { return mState; }
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(change)
|
|
|
|
|
|
|
|
private:
|
2015-07-31 14:56:59 -07:00
|
|
|
~PermissionStatus();
|
|
|
|
|
2016-01-30 09:05:36 -08:00
|
|
|
PermissionStatus(nsPIDOMWindowInner* aWindow, PermissionName aName);
|
2015-08-21 19:53:29 -07:00
|
|
|
|
2015-08-21 19:53:29 -07:00
|
|
|
nsresult Init();
|
|
|
|
|
2015-08-21 19:53:29 -07:00
|
|
|
nsresult UpdateState();
|
2015-07-28 06:33:46 -07:00
|
|
|
|
2016-11-08 18:53:11 +08:00
|
|
|
already_AddRefed<nsIPrincipal> GetPrincipal() const;
|
2015-08-21 19:53:29 -07:00
|
|
|
|
2015-08-21 19:53:29 -07:00
|
|
|
void PermissionChanged();
|
2015-08-21 19:53:29 -07:00
|
|
|
|
2015-08-21 19:53:29 -07:00
|
|
|
PermissionName mName;
|
2015-07-28 06:33:46 -07:00
|
|
|
PermissionState mState;
|
2015-08-21 19:53:29 -07:00
|
|
|
|
2015-10-18 01:24:48 -04:00
|
|
|
RefPtr<PermissionObserver> mObserver;
|
2015-07-28 06:33:46 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_permissionstatus_h_
|