2017-10-27 01:08:41 +03: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: */
|
2015-09-14 05:39:57 +03:00
|
|
|
/* 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_PresentationAvailability_h
|
|
|
|
#define mozilla_dom_PresentationAvailability_h
|
|
|
|
|
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2015-09-10 11:29:08 +03:00
|
|
|
#include "nsIPresentationListener.h"
|
2016-08-31 05:31:15 +03:00
|
|
|
#include "nsTArray.h"
|
2015-09-14 05:39:57 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2016-08-31 05:31:15 +03:00
|
|
|
class Promise;
|
|
|
|
|
2015-09-14 05:39:57 +03:00
|
|
|
class PresentationAvailability final
|
|
|
|
: public DOMEventTargetHelper,
|
2015-09-10 11:29:08 +03:00
|
|
|
public nsIPresentationAvailabilityListener,
|
2016-08-17 11:15:32 +03:00
|
|
|
public SupportsWeakPtr<PresentationAvailability> {
|
2015-09-14 05:39:57 +03:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PresentationAvailability,
|
|
|
|
DOMEventTargetHelper)
|
2015-09-10 11:29:08 +03:00
|
|
|
NS_DECL_NSIPRESENTATIONAVAILABILITYLISTENER
|
2016-08-17 11:15:32 +03:00
|
|
|
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(PresentationAvailability)
|
2015-09-14 05:39:57 +03:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
static already_AddRefed<PresentationAvailability> Create(
|
2016-09-05 02:17:00 +03:00
|
|
|
nsPIDOMWindowInner* aWindow, const nsTArray<nsString>& aUrls,
|
2016-08-31 05:31:15 +03:00
|
|
|
RefPtr<Promise>& aPromise);
|
2015-09-14 05:39:57 +03:00
|
|
|
|
2015-09-10 11:29:08 +03:00
|
|
|
virtual void DisconnectFromOwner() override;
|
|
|
|
|
2015-09-14 05:39:57 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
2016-09-05 02:17:00 +03:00
|
|
|
bool Equals(const uint64_t aWindowID, const nsTArray<nsString>& aUrls) const;
|
2016-08-17 11:15:32 +03:00
|
|
|
|
|
|
|
bool IsCachedValueReady();
|
|
|
|
|
|
|
|
void EnqueuePromise(RefPtr<Promise>& aPromise);
|
|
|
|
|
2015-09-14 05:39:57 +03:00
|
|
|
// WebIDL (public APIs)
|
|
|
|
bool Value() const;
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(change);
|
|
|
|
|
|
|
|
private:
|
2016-08-17 11:15:32 +03:00
|
|
|
explicit PresentationAvailability(nsPIDOMWindowInner* aWindow,
|
2016-09-05 02:17:00 +03:00
|
|
|
const nsTArray<nsString>& aUrls);
|
2015-09-14 05:39:57 +03:00
|
|
|
|
2016-08-31 05:31:15 +03:00
|
|
|
virtual ~PresentationAvailability();
|
2015-09-14 05:39:57 +03:00
|
|
|
|
2016-08-31 05:31:15 +03:00
|
|
|
bool Init(RefPtr<Promise>& aPromise);
|
2015-09-14 05:39:57 +03:00
|
|
|
|
|
|
|
void Shutdown();
|
|
|
|
|
2015-09-10 11:29:08 +03:00
|
|
|
void UpdateAvailabilityAndDispatchEvent(bool aIsAvailable);
|
|
|
|
|
2015-09-14 05:39:57 +03:00
|
|
|
bool mIsAvailable;
|
2016-08-31 05:31:15 +03:00
|
|
|
|
2016-08-17 11:15:32 +03:00
|
|
|
nsTArray<RefPtr<Promise>> mPromises;
|
|
|
|
|
2016-09-05 02:17:00 +03:00
|
|
|
nsTArray<nsString> mUrls;
|
2016-11-08 06:13:00 +03:00
|
|
|
nsTArray<bool> mAvailabilityOfUrl;
|
2015-09-14 05:39:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_PresentationAvailability_h
|