2015-05-03 22:32:37 +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: */
|
2012-05-21 15:12:37 +04: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 09:21:26 +03:00
|
|
|
|
2016-03-19 00:15:46 +03:00
|
|
|
#ifndef mozilla_dom_workernavigator_h__
|
|
|
|
#define mozilla_dom_workernavigator_h__
|
2011-07-17 23:09:13 +04:00
|
|
|
|
2018-01-30 12:10:04 +03:00
|
|
|
#include "WorkerCommon.h"
|
2013-09-23 21:25:00 +04:00
|
|
|
#include "nsString.h"
|
2013-09-30 08:15:37 +04:00
|
|
|
#include "nsWrapperCache.h"
|
2016-11-16 01:44:43 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2016-09-07 11:24:25 +03:00
|
|
|
#include "mozilla/dom/StorageManager.h"
|
2018-01-31 10:25:30 +03:00
|
|
|
#include "mozilla/dom/workerinternals/RuntimeService.h"
|
2011-07-17 23:09:13 +04:00
|
|
|
|
2014-02-24 17:57:15 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Promise;
|
2016-06-14 15:57:36 +03:00
|
|
|
class StorageManager;
|
2018-05-31 15:32:51 +03:00
|
|
|
class MediaCapabilities;
|
2011-07-17 23:09:13 +04:00
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
namespace network {
|
|
|
|
class Connection;
|
|
|
|
} // namespace network
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class WorkerNavigator final : public nsWrapperCache
|
2013-07-24 11:38:23 +04:00
|
|
|
{
|
2018-01-31 10:24:59 +03:00
|
|
|
typedef struct workerinternals::RuntimeService::NavigatorProperties NavigatorProperties;
|
2014-09-23 23:11:18 +04:00
|
|
|
|
|
|
|
NavigatorProperties mProperties;
|
2016-06-14 15:57:36 +03:00
|
|
|
RefPtr<StorageManager> mStorageManager;
|
2016-12-16 10:50:23 +03:00
|
|
|
RefPtr<network::Connection> mConnection;
|
2013-11-20 03:08:50 +04:00
|
|
|
bool mOnline;
|
2013-07-24 11:38:23 +04:00
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
WorkerNavigator(const NavigatorProperties& aProperties, bool aOnline);
|
|
|
|
~WorkerNavigator();
|
2014-06-23 23:56:07 +04:00
|
|
|
|
2013-07-24 11:38:23 +04:00
|
|
|
public:
|
2013-09-30 08:15:37 +04:00
|
|
|
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerNavigator)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WorkerNavigator)
|
|
|
|
|
2013-07-24 11:38:23 +04:00
|
|
|
static already_AddRefed<WorkerNavigator>
|
2013-11-20 03:08:50 +04:00
|
|
|
Create(bool aOnLine);
|
2013-07-24 11:38:23 +04:00
|
|
|
|
2013-09-30 08:15:37 +04:00
|
|
|
virtual JSObject*
|
2015-03-21 19:28:04 +03:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2011-07-17 23:09:13 +04:00
|
|
|
|
2013-09-30 08:15:37 +04:00
|
|
|
nsISupports* GetParentObject() const {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2011-07-17 23:09:13 +04:00
|
|
|
|
2018-01-22 20:59:15 +03:00
|
|
|
void GetAppCodeName(nsString& aAppCodeName, ErrorResult& /* unused */) const
|
2013-11-20 18:29:01 +04:00
|
|
|
{
|
|
|
|
aAppCodeName.AssignLiteral("Mozilla");
|
|
|
|
}
|
2016-11-16 01:44:43 +03:00
|
|
|
void GetAppName(nsString& aAppName, CallerType aCallerType) const;
|
2013-11-20 03:08:50 +04:00
|
|
|
|
2016-11-16 01:44:43 +03:00
|
|
|
void GetAppVersion(nsString& aAppVersion, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) const;
|
2014-09-23 23:11:18 +04:00
|
|
|
|
2016-11-16 01:44:43 +03:00
|
|
|
void GetPlatform(nsString& aPlatform, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) const;
|
2013-11-20 03:08:50 +04:00
|
|
|
|
2013-11-20 18:29:01 +04:00
|
|
|
void GetProduct(nsString& aProduct) const
|
|
|
|
{
|
|
|
|
aProduct.AssignLiteral("Gecko");
|
|
|
|
}
|
2014-09-23 23:11:18 +04:00
|
|
|
|
2013-11-20 18:29:01 +04:00
|
|
|
bool TaintEnabled() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-11-20 03:08:50 +04:00
|
|
|
|
2014-09-05 18:26:34 +04:00
|
|
|
void GetLanguage(nsString& aLanguage) const
|
|
|
|
{
|
2014-09-23 23:11:18 +04:00
|
|
|
if (mProperties.mLanguages.Length() >= 1) {
|
|
|
|
aLanguage.Assign(mProperties.mLanguages[0]);
|
2014-09-05 18:26:34 +04:00
|
|
|
} else {
|
|
|
|
aLanguage.Truncate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetLanguages(nsTArray<nsString>& aLanguages) const
|
|
|
|
{
|
2014-09-23 23:11:18 +04:00
|
|
|
aLanguages = mProperties.mLanguages;
|
2014-09-05 18:26:34 +04:00
|
|
|
}
|
|
|
|
|
2016-11-16 01:44:43 +03:00
|
|
|
void GetUserAgent(nsString& aUserAgent, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) const;
|
2013-11-20 03:08:50 +04:00
|
|
|
|
|
|
|
bool OnLine() const
|
|
|
|
{
|
|
|
|
return mOnline;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Worker thread only!
|
|
|
|
void SetOnLine(bool aOnline)
|
|
|
|
{
|
|
|
|
mOnline = aOnline;
|
|
|
|
}
|
2014-02-24 17:57:15 +04:00
|
|
|
|
2014-09-05 18:26:34 +04:00
|
|
|
void SetLanguages(const nsTArray<nsString>& aLanguages);
|
|
|
|
|
2016-03-16 22:41:38 +03:00
|
|
|
uint64_t HardwareConcurrency() const;
|
2016-06-14 15:57:36 +03:00
|
|
|
|
|
|
|
StorageManager* Storage();
|
2016-12-16 10:50:23 +03:00
|
|
|
|
|
|
|
network::Connection* GetConnection(ErrorResult& aRv);
|
2018-05-31 15:32:51 +03:00
|
|
|
|
|
|
|
dom::MediaCapabilities* MediaCapabilities();
|
|
|
|
|
|
|
|
private:
|
|
|
|
RefPtr<dom::MediaCapabilities> mMediaCapabilities;
|
2013-09-30 06:41:23 +04:00
|
|
|
};
|
2013-09-30 08:15:37 +04:00
|
|
|
|
2016-03-19 00:15:46 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2011-07-17 23:09:13 +04:00
|
|
|
|
2016-03-19 00:15:46 +03:00
|
|
|
#endif // mozilla_dom_workernavigator_h__
|