|
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/. */ |
|
5 |
|
6 #ifndef mozilla_dom_workers_navigator_h__ |
|
7 #define mozilla_dom_workers_navigator_h__ |
|
8 |
|
9 #include "Workers.h" |
|
10 #include "RuntimeService.h" |
|
11 #include "nsString.h" |
|
12 #include "nsWrapperCache.h" |
|
13 |
|
14 BEGIN_WORKERS_NAMESPACE |
|
15 |
|
16 class WorkerNavigator MOZ_FINAL : public nsWrapperCache |
|
17 { |
|
18 typedef struct RuntimeService::NavigatorProperties NavigatorProperties; |
|
19 |
|
20 NavigatorProperties mProperties; |
|
21 bool mOnline; |
|
22 |
|
23 WorkerNavigator(const NavigatorProperties& aProperties, |
|
24 bool aOnline) |
|
25 : mProperties(aProperties) |
|
26 , mOnline(aOnline) |
|
27 { |
|
28 MOZ_COUNT_CTOR(WorkerNavigator); |
|
29 SetIsDOMBinding(); |
|
30 } |
|
31 |
|
32 public: |
|
33 |
|
34 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerNavigator) |
|
35 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WorkerNavigator) |
|
36 |
|
37 static already_AddRefed<WorkerNavigator> |
|
38 Create(bool aOnLine); |
|
39 |
|
40 virtual JSObject* |
|
41 WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
42 |
|
43 nsISupports* GetParentObject() const { |
|
44 return nullptr; |
|
45 } |
|
46 |
|
47 ~WorkerNavigator() |
|
48 { |
|
49 MOZ_COUNT_DTOR(WorkerNavigator); |
|
50 } |
|
51 |
|
52 void GetAppCodeName(nsString& aAppCodeName) const |
|
53 { |
|
54 aAppCodeName.AssignLiteral("Mozilla"); |
|
55 } |
|
56 void GetAppName(nsString& aAppName) const; |
|
57 |
|
58 void GetAppVersion(nsString& aAppVersion) const; |
|
59 |
|
60 void GetPlatform(nsString& aPlatform) const; |
|
61 |
|
62 void GetProduct(nsString& aProduct) const |
|
63 { |
|
64 aProduct.AssignLiteral("Gecko"); |
|
65 } |
|
66 |
|
67 bool TaintEnabled() const |
|
68 { |
|
69 return false; |
|
70 } |
|
71 |
|
72 void GetUserAgent(nsString& aUserAgent) const |
|
73 { |
|
74 aUserAgent = mProperties.mUserAgent; |
|
75 } |
|
76 |
|
77 bool OnLine() const |
|
78 { |
|
79 return mOnline; |
|
80 } |
|
81 |
|
82 // Worker thread only! |
|
83 void SetOnLine(bool aOnline) |
|
84 { |
|
85 mOnline = aOnline; |
|
86 } |
|
87 }; |
|
88 |
|
89 END_WORKERS_NAMESPACE |
|
90 |
|
91 #endif // mozilla_dom_workers_navigator_h__ |