1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
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
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_dom_workers_navigator_h__
7 #define mozilla_dom_workers_navigator_h__
10 #include "RuntimeService.h"
12 #include "nsWrapperCache.h"
14 // Need this to use Navigator::HasDataStoreSupport() in
15 // WorkerNavigatorBinding.cpp
16 #include "mozilla/dom/Navigator.h"
24 BEGIN_WORKERS_NAMESPACE
26 class WorkerNavigator MOZ_FINAL
: public nsWrapperCache
28 typedef struct RuntimeService::NavigatorProperties NavigatorProperties
;
30 NavigatorProperties mProperties
;
33 WorkerNavigator(const NavigatorProperties
& aProperties
,
35 : mProperties(aProperties
)
38 MOZ_COUNT_CTOR(WorkerNavigator
);
43 MOZ_COUNT_DTOR(WorkerNavigator
);
48 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerNavigator
)
49 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WorkerNavigator
)
51 static already_AddRefed
<WorkerNavigator
>
55 WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
57 nsISupports
* GetParentObject() const {
61 void GetAppCodeName(nsString
& aAppCodeName
) const
63 aAppCodeName
.AssignLiteral("Mozilla");
65 void GetAppName(nsString
& aAppName
) const;
67 void GetAppVersion(nsString
& aAppVersion
) const;
69 void GetPlatform(nsString
& aPlatform
) const;
71 void GetProduct(nsString
& aProduct
) const
73 aProduct
.AssignLiteral("Gecko");
76 bool TaintEnabled() const
81 void GetLanguage(nsString
& aLanguage
) const
83 if (mProperties
.mLanguages
.Length() >= 1) {
84 aLanguage
.Assign(mProperties
.mLanguages
[0]);
90 void GetLanguages(nsTArray
<nsString
>& aLanguages
) const
92 aLanguages
= mProperties
.mLanguages
;
95 void GetUserAgent(nsString
& aUserAgent
) const;
102 // Worker thread only!
103 void SetOnLine(bool aOnline
)
108 void SetLanguages(const nsTArray
<nsString
>& aLanguages
);
110 already_AddRefed
<Promise
> GetDataStores(JSContext
* aCx
,
111 const nsAString
& aName
,
112 const nsAString
& aOwner
,
116 END_WORKERS_NAMESPACE
118 #endif // mozilla_dom_workers_navigator_h__