michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_workers_navigator_h__ michael@0: #define mozilla_dom_workers_navigator_h__ michael@0: michael@0: #include "Workers.h" michael@0: #include "RuntimeService.h" michael@0: #include "nsString.h" michael@0: #include "nsWrapperCache.h" michael@0: michael@0: BEGIN_WORKERS_NAMESPACE michael@0: michael@0: class WorkerNavigator MOZ_FINAL : public nsWrapperCache michael@0: { michael@0: typedef struct RuntimeService::NavigatorProperties NavigatorProperties; michael@0: michael@0: NavigatorProperties mProperties; michael@0: bool mOnline; michael@0: michael@0: WorkerNavigator(const NavigatorProperties& aProperties, michael@0: bool aOnline) michael@0: : mProperties(aProperties) michael@0: , mOnline(aOnline) michael@0: { michael@0: MOZ_COUNT_CTOR(WorkerNavigator); michael@0: SetIsDOMBinding(); michael@0: } michael@0: michael@0: public: michael@0: michael@0: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerNavigator) michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WorkerNavigator) michael@0: michael@0: static already_AddRefed michael@0: Create(bool aOnLine); michael@0: michael@0: virtual JSObject* michael@0: WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: nsISupports* GetParentObject() const { michael@0: return nullptr; michael@0: } michael@0: michael@0: ~WorkerNavigator() michael@0: { michael@0: MOZ_COUNT_DTOR(WorkerNavigator); michael@0: } michael@0: michael@0: void GetAppCodeName(nsString& aAppCodeName) const michael@0: { michael@0: aAppCodeName.AssignLiteral("Mozilla"); michael@0: } michael@0: void GetAppName(nsString& aAppName) const; michael@0: michael@0: void GetAppVersion(nsString& aAppVersion) const; michael@0: michael@0: void GetPlatform(nsString& aPlatform) const; michael@0: michael@0: void GetProduct(nsString& aProduct) const michael@0: { michael@0: aProduct.AssignLiteral("Gecko"); michael@0: } michael@0: michael@0: bool TaintEnabled() const michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: void GetUserAgent(nsString& aUserAgent) const michael@0: { michael@0: aUserAgent = mProperties.mUserAgent; michael@0: } michael@0: michael@0: bool OnLine() const michael@0: { michael@0: return mOnline; michael@0: } michael@0: michael@0: // Worker thread only! michael@0: void SetOnLine(bool aOnline) michael@0: { michael@0: mOnline = aOnline; michael@0: } michael@0: }; michael@0: michael@0: END_WORKERS_NAMESPACE michael@0: michael@0: #endif // mozilla_dom_workers_navigator_h__