2015-05-03 19:32:37 +00: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: */
|
2012-05-21 11:12:37 +00: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/. */
|
2011-01-07 06:21:26 +00:00
|
|
|
|
2016-03-18 21:15:46 +00:00
|
|
|
#ifndef mozilla_dom_workernavigator_h__
|
|
|
|
#define mozilla_dom_workernavigator_h__
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2020-07-15 12:45:12 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include "js/RootingAPI.h"
|
|
|
|
#include "mozilla/AlreadyAddRefed.h"
|
|
|
|
#include "mozilla/Assertions.h"
|
|
|
|
#include "mozilla/RefPtr.h"
|
2016-11-15 22:44:43 +00:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2018-01-31 07:25:30 +00:00
|
|
|
#include "mozilla/dom/workerinternals/RuntimeService.h"
|
2023-02-06 11:26:04 +00:00
|
|
|
#include "mozilla/StaticPrefs_privacy.h"
|
2020-07-15 12:45:12 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsStringFwd.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2014-02-24 13:57:15 +00:00
|
|
|
namespace mozilla {
|
2020-11-23 16:12:02 +00:00
|
|
|
class ErrorResult;
|
|
|
|
|
2019-10-02 16:46:03 +00:00
|
|
|
namespace webgpu {
|
|
|
|
class Instance;
|
|
|
|
} // namespace webgpu
|
2014-02-24 13:57:15 +00:00
|
|
|
namespace dom {
|
2016-06-14 12:57:36 +00:00
|
|
|
class StorageManager;
|
2018-05-31 12:32:51 +00:00
|
|
|
class MediaCapabilities;
|
2021-08-18 01:23:45 +00:00
|
|
|
class LockManager;
|
2024-10-11 06:53:48 +00:00
|
|
|
class Permissions;
|
2024-10-24 03:02:40 +00:00
|
|
|
class ServiceWorkerContainer;
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2016-12-16 07:50:23 +00:00
|
|
|
namespace network {
|
|
|
|
class Connection;
|
|
|
|
} // namespace network
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class WorkerNavigator final : public nsWrapperCache {
|
2021-08-11 14:41:34 +00:00
|
|
|
using NavigatorProperties =
|
|
|
|
workerinternals::RuntimeService::NavigatorProperties;
|
2014-09-23 19:11:18 +00:00
|
|
|
|
|
|
|
NavigatorProperties mProperties;
|
2016-06-14 12:57:36 +00:00
|
|
|
RefPtr<StorageManager> mStorageManager;
|
2016-12-16 07:50:23 +00:00
|
|
|
RefPtr<network::Connection> mConnection;
|
2019-10-02 16:46:03 +00:00
|
|
|
RefPtr<dom::MediaCapabilities> mMediaCapabilities;
|
|
|
|
RefPtr<webgpu::Instance> mWebGpu;
|
2021-08-18 01:23:45 +00:00
|
|
|
RefPtr<dom::LockManager> mLocks;
|
2024-10-11 06:53:48 +00:00
|
|
|
RefPtr<dom::Permissions> mPermissions;
|
2024-10-24 03:02:40 +00:00
|
|
|
RefPtr<ServiceWorkerContainer> mServiceWorkerContainer;
|
2013-11-19 23:08:50 +00:00
|
|
|
bool mOnline;
|
2013-07-24 07:38:23 +00:00
|
|
|
|
2016-12-16 07:50:23 +00:00
|
|
|
WorkerNavigator(const NavigatorProperties& aProperties, bool aOnline);
|
|
|
|
~WorkerNavigator();
|
2014-06-23 19:56:07 +00:00
|
|
|
|
2013-07-24 07:38:23 +00:00
|
|
|
public:
|
2013-09-30 04:15:37 +00:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerNavigator)
|
2022-09-07 11:22:51 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(WorkerNavigator)
|
2013-09-30 04:15:37 +00:00
|
|
|
|
2013-07-24 07:38:23 +00:00
|
|
|
static already_AddRefed<WorkerNavigator> Create(bool aOnLine);
|
|
|
|
|
2022-08-31 09:34:50 +00:00
|
|
|
void Invalidate();
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2013-09-30 04:15:37 +00:00
|
|
|
nsISupports* GetParentObject() const { return nullptr; }
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2018-01-22 17:59:15 +00:00
|
|
|
void GetAppCodeName(nsString& aAppCodeName, ErrorResult& /* unused */) const {
|
2013-11-20 14:29:01 +00:00
|
|
|
aAppCodeName.AssignLiteral("Mozilla");
|
|
|
|
}
|
2023-07-19 17:00:53 +00:00
|
|
|
void GetAppName(nsString& aAppName) const {
|
|
|
|
aAppName.AssignLiteral("Netscape");
|
|
|
|
}
|
2013-11-19 23:08:50 +00:00
|
|
|
|
2016-11-15 22:44:43 +00:00
|
|
|
void GetAppVersion(nsString& aAppVersion, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) const;
|
2014-09-23 19:11:18 +00:00
|
|
|
|
2016-11-15 22:44:43 +00:00
|
|
|
void GetPlatform(nsString& aPlatform, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) const;
|
2013-11-19 23:08:50 +00:00
|
|
|
|
2013-11-20 14:29:01 +00:00
|
|
|
void GetProduct(nsString& aProduct) const { aProduct.AssignLiteral("Gecko"); }
|
2014-09-23 19:11:18 +00:00
|
|
|
|
2013-11-20 14:29:01 +00:00
|
|
|
bool TaintEnabled() const { return false; }
|
2013-11-19 23:08:50 +00:00
|
|
|
|
2014-09-05 14:26:34 +00:00
|
|
|
void GetLanguage(nsString& aLanguage) const {
|
2020-04-27 20:16:04 +00:00
|
|
|
MOZ_ASSERT(mProperties.mLanguages.Length() >= 1);
|
|
|
|
aLanguage.Assign(mProperties.mLanguages[0]);
|
2014-09-05 14:26:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GetLanguages(nsTArray<nsString>& aLanguages) const {
|
2020-05-11 08:22:17 +00:00
|
|
|
aLanguages = mProperties.mLanguages.Clone();
|
2014-09-05 14:26:34 +00:00
|
|
|
}
|
|
|
|
|
2016-11-15 22:44:43 +00:00
|
|
|
void GetUserAgent(nsString& aUserAgent, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) const;
|
2013-11-19 23:08:50 +00:00
|
|
|
|
|
|
|
bool OnLine() const { return mOnline; }
|
|
|
|
|
|
|
|
// Worker thread only!
|
|
|
|
void SetOnLine(bool aOnline) { mOnline = aOnline; }
|
2014-02-24 13:57:15 +00:00
|
|
|
|
2023-10-18 13:30:51 +00:00
|
|
|
bool GlobalPrivacyControl() const;
|
2023-02-06 11:26:04 +00:00
|
|
|
|
2014-09-05 14:26:34 +00:00
|
|
|
void SetLanguages(const nsTArray<nsString>& aLanguages);
|
|
|
|
|
2016-03-16 19:41:38 +00:00
|
|
|
uint64_t HardwareConcurrency() const;
|
2016-06-14 12:57:36 +00:00
|
|
|
|
|
|
|
StorageManager* Storage();
|
2016-12-16 07:50:23 +00:00
|
|
|
|
|
|
|
network::Connection* GetConnection(ErrorResult& aRv);
|
2018-05-31 12:32:51 +00:00
|
|
|
|
|
|
|
dom::MediaCapabilities* MediaCapabilities();
|
|
|
|
|
2019-10-02 16:46:03 +00:00
|
|
|
webgpu::Instance* Gpu();
|
2021-08-18 01:23:45 +00:00
|
|
|
|
|
|
|
dom::LockManager* Locks();
|
2024-10-11 06:53:48 +00:00
|
|
|
|
|
|
|
dom::Permissions* Permissions();
|
2024-10-24 03:02:40 +00:00
|
|
|
|
|
|
|
already_AddRefed<ServiceWorkerContainer> ServiceWorker();
|
2013-09-30 02:41:23 +00:00
|
|
|
};
|
2013-09-30 04:15:37 +00:00
|
|
|
|
2016-03-18 21:15:46 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2016-03-18 21:15:46 +00:00
|
|
|
#endif // mozilla_dom_workernavigator_h__
|