ServiceWorkerWindowClient.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/.
  5. */
  6. #ifndef mozilla_dom_workers_serviceworkerwindowclient_h
  7. #define mozilla_dom_workers_serviceworkerwindowclient_h
  8. #include "ServiceWorkerClient.h"
  9. namespace mozilla {
  10. namespace dom {
  11. class Promise;
  12. namespace workers {
  13. class ServiceWorkerWindowClient final : public ServiceWorkerClient
  14. {
  15. public:
  16. ServiceWorkerWindowClient(nsISupports* aOwner,
  17. const ServiceWorkerClientInfo& aClientInfo)
  18. : ServiceWorkerClient(aOwner, aClientInfo),
  19. mVisibilityState(aClientInfo.mVisibilityState),
  20. mFocused(aClientInfo.mFocused)
  21. {
  22. }
  23. virtual JSObject*
  24. WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  25. mozilla::dom::VisibilityState
  26. VisibilityState() const
  27. {
  28. return mVisibilityState;
  29. }
  30. bool
  31. Focused() const
  32. {
  33. return mFocused;
  34. }
  35. already_AddRefed<Promise>
  36. Focus(ErrorResult& aRv) const;
  37. already_AddRefed<Promise>
  38. Navigate(const nsAString& aUrl, ErrorResult& aRv);
  39. private:
  40. ~ServiceWorkerWindowClient()
  41. { }
  42. mozilla::dom::VisibilityState mVisibilityState;
  43. bool mFocused;
  44. };
  45. } // namespace workers
  46. } // namespace dom
  47. } // namespace mozilla
  48. #endif // mozilla_dom_workers_serviceworkerwindowclient_h