2011-07-17 23:09:13 +04:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
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
|
|
|
|
2011-07-17 23:09:13 +04:00
|
|
|
#ifndef mozilla_dom_workers_navigator_h__
|
|
|
|
#define mozilla_dom_workers_navigator_h__
|
|
|
|
|
|
|
|
#include "Workers.h"
|
2013-09-23 21:25:00 +04:00
|
|
|
#include "nsString.h"
|
2013-09-30 08:15:37 +04:00
|
|
|
#include "nsWrapperCache.h"
|
2011-07-17 23:09:13 +04:00
|
|
|
|
|
|
|
BEGIN_WORKERS_NAMESPACE
|
|
|
|
|
2013-09-30 08:15:37 +04:00
|
|
|
class WorkerNavigator MOZ_FINAL : public nsWrapperCache
|
2013-07-24 11:38:23 +04:00
|
|
|
{
|
|
|
|
nsString mAppName;
|
|
|
|
nsString mAppVersion;
|
|
|
|
nsString mPlatform;
|
|
|
|
nsString mUserAgent;
|
2013-11-20 03:08:50 +04:00
|
|
|
bool mOnline;
|
2013-07-24 11:38:23 +04:00
|
|
|
|
2013-09-30 08:15:37 +04:00
|
|
|
WorkerNavigator(const nsAString& aAppName,
|
2013-07-24 11:38:23 +04:00
|
|
|
const nsAString& aAppVersion,
|
|
|
|
const nsAString& aPlatform,
|
2013-11-20 03:08:50 +04:00
|
|
|
const nsAString& aUserAgent,
|
|
|
|
bool aOnline)
|
2013-09-30 08:15:37 +04:00
|
|
|
: mAppName(aAppName)
|
2013-07-24 11:38:23 +04:00
|
|
|
, mAppVersion(aAppVersion)
|
|
|
|
, mPlatform(aPlatform)
|
|
|
|
, mUserAgent(aUserAgent)
|
2013-11-20 03:08:50 +04:00
|
|
|
, mOnline(aOnline)
|
2013-07-24 11:38:23 +04:00
|
|
|
{
|
2013-09-30 08:15:37 +04:00
|
|
|
MOZ_COUNT_CTOR(WorkerNavigator);
|
|
|
|
SetIsDOMBinding();
|
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*
|
2014-04-09 02:27:18 +04:00
|
|
|
WrapObject(JSContext* aCx) MOZ_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
|
|
|
|
2013-07-24 11:38:23 +04:00
|
|
|
~WorkerNavigator()
|
|
|
|
{
|
2013-09-30 08:15:37 +04:00
|
|
|
MOZ_COUNT_DTOR(WorkerNavigator);
|
2013-07-24 11:38:23 +04:00
|
|
|
}
|
2011-07-17 23:09:13 +04:00
|
|
|
|
2013-11-20 18:29:01 +04:00
|
|
|
void GetAppCodeName(nsString& aAppCodeName) const
|
|
|
|
{
|
|
|
|
aAppCodeName.AssignLiteral("Mozilla");
|
|
|
|
}
|
2013-07-24 11:38:23 +04:00
|
|
|
void GetAppName(nsString& aAppName) const
|
|
|
|
{
|
|
|
|
aAppName = mAppName;
|
|
|
|
}
|
2013-11-20 03:08:50 +04:00
|
|
|
|
2013-07-24 11:38:23 +04:00
|
|
|
void GetAppVersion(nsString& aAppVersion) const
|
|
|
|
{
|
|
|
|
aAppVersion = mAppVersion;
|
|
|
|
}
|
2013-11-20 03:08:50 +04:00
|
|
|
|
2013-07-24 11:38:23 +04:00
|
|
|
void GetPlatform(nsString& aPlatform) const
|
|
|
|
{
|
|
|
|
aPlatform = mPlatform;
|
|
|
|
}
|
2013-11-20 18:29:01 +04:00
|
|
|
void GetProduct(nsString& aProduct) const
|
|
|
|
{
|
|
|
|
aProduct.AssignLiteral("Gecko");
|
|
|
|
}
|
|
|
|
bool TaintEnabled() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-11-20 03:08:50 +04:00
|
|
|
|
2013-07-24 11:38:23 +04:00
|
|
|
void GetUserAgent(nsString& aUserAgent) const
|
|
|
|
{
|
|
|
|
aUserAgent = mUserAgent;
|
|
|
|
}
|
2013-11-20 03:08:50 +04:00
|
|
|
|
|
|
|
bool OnLine() const
|
|
|
|
{
|
|
|
|
return mOnline;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Worker thread only!
|
|
|
|
void SetOnLine(bool aOnline)
|
|
|
|
{
|
|
|
|
mOnline = aOnline;
|
|
|
|
}
|
2013-09-30 06:41:23 +04:00
|
|
|
};
|
2013-09-30 08:15:37 +04:00
|
|
|
|
2011-07-17 23:09:13 +04:00
|
|
|
END_WORKERS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_workers_navigator_h__
|