Bumping gaia.json for 4 gaia revision(s) a=gaia-bump
[gecko.git] / dom / workers / Navigator.h
blob64beb36f7cba46c172eb2eb9281f8d9c93333ed3
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__
9 #include "Workers.h"
10 #include "RuntimeService.h"
11 #include "nsString.h"
12 #include "nsWrapperCache.h"
14 // Need this to use Navigator::HasDataStoreSupport() in
15 // WorkerNavigatorBinding.cpp
16 #include "mozilla/dom/Navigator.h"
18 namespace mozilla {
19 namespace dom {
20 class Promise;
24 BEGIN_WORKERS_NAMESPACE
26 class WorkerNavigator MOZ_FINAL : public nsWrapperCache
28 typedef struct RuntimeService::NavigatorProperties NavigatorProperties;
30 NavigatorProperties mProperties;
31 bool mOnline;
33 WorkerNavigator(const NavigatorProperties& aProperties,
34 bool aOnline)
35 : mProperties(aProperties)
36 , mOnline(aOnline)
38 MOZ_COUNT_CTOR(WorkerNavigator);
41 ~WorkerNavigator()
43 MOZ_COUNT_DTOR(WorkerNavigator);
46 public:
48 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerNavigator)
49 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WorkerNavigator)
51 static already_AddRefed<WorkerNavigator>
52 Create(bool aOnLine);
54 virtual JSObject*
55 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
57 nsISupports* GetParentObject() const {
58 return nullptr;
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
78 return false;
81 void GetLanguage(nsString& aLanguage) const
83 if (mProperties.mLanguages.Length() >= 1) {
84 aLanguage.Assign(mProperties.mLanguages[0]);
85 } else {
86 aLanguage.Truncate();
90 void GetLanguages(nsTArray<nsString>& aLanguages) const
92 aLanguages = mProperties.mLanguages;
95 void GetUserAgent(nsString& aUserAgent) const;
97 bool OnLine() const
99 return mOnline;
102 // Worker thread only!
103 void SetOnLine(bool aOnline)
105 mOnline = aOnline;
108 void SetLanguages(const nsTArray<nsString>& aLanguages);
110 already_AddRefed<Promise> GetDataStores(JSContext* aCx,
111 const nsAString& aName,
112 const nsAString& aOwner,
113 ErrorResult& aRv);
116 END_WORKERS_NAMESPACE
118 #endif // mozilla_dom_workers_navigator_h__