|
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
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 file, |
|
4 * You can obtain one at http://mozilla.org/MPL/2.0/. |
|
5 * |
|
6 * The origin of this IDL file is |
|
7 * http://www.whatwg.org/specs/web-apps/current-work/#the-navigator-object |
|
8 * http://www.w3.org/TR/tracking-dnt/ |
|
9 * http://www.w3.org/TR/geolocation-API/#geolocation_interface |
|
10 * http://www.w3.org/TR/battery-status/#navigatorbattery-interface |
|
11 * http://www.w3.org/TR/vibration/#vibration-interface |
|
12 * http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1 |
|
13 * https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension |
|
14 * http://www.w3.org/TR/beacon/#sec-beacon-method |
|
15 * |
|
16 * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and |
|
17 * Opera Software ASA. You are granted a license to use, reproduce |
|
18 * and create derivative works of this document. |
|
19 */ |
|
20 |
|
21 // http://www.whatwg.org/specs/web-apps/current-work/#the-navigator-object |
|
22 [HeaderFile="Navigator.h", NeedNewResolve] |
|
23 interface Navigator { |
|
24 // objects implementing this interface also implement the interfaces given below |
|
25 }; |
|
26 Navigator implements NavigatorID; |
|
27 Navigator implements NavigatorLanguage; |
|
28 Navigator implements NavigatorOnLine; |
|
29 Navigator implements NavigatorContentUtils; |
|
30 Navigator implements NavigatorStorageUtils; |
|
31 |
|
32 [NoInterfaceObject] |
|
33 interface NavigatorID { |
|
34 // WebKit/Blink/Trident/Presto support this (hardcoded "Mozilla"). |
|
35 [Constant] |
|
36 readonly attribute DOMString appCodeName; // constant "Mozilla" |
|
37 [Constant] |
|
38 readonly attribute DOMString appName; |
|
39 [Constant] |
|
40 readonly attribute DOMString appVersion; |
|
41 [Constant] |
|
42 readonly attribute DOMString platform; |
|
43 [Constant] |
|
44 readonly attribute DOMString userAgent; |
|
45 [Constant] |
|
46 readonly attribute DOMString product; // constant "Gecko" |
|
47 |
|
48 // Everyone but WebKit/Blink supports this. See bug 679971. |
|
49 boolean taintEnabled(); // constant false |
|
50 }; |
|
51 |
|
52 [NoInterfaceObject] |
|
53 interface NavigatorLanguage { |
|
54 readonly attribute DOMString? language; |
|
55 }; |
|
56 |
|
57 [NoInterfaceObject] |
|
58 interface NavigatorOnLine { |
|
59 readonly attribute boolean onLine; |
|
60 }; |
|
61 |
|
62 [NoInterfaceObject] |
|
63 interface NavigatorContentUtils { |
|
64 // content handler registration |
|
65 [Throws] |
|
66 void registerProtocolHandler(DOMString scheme, DOMString url, DOMString title); |
|
67 [Throws] |
|
68 void registerContentHandler(DOMString mimeType, DOMString url, DOMString title); |
|
69 // NOT IMPLEMENTED |
|
70 //DOMString isProtocolHandlerRegistered(DOMString scheme, DOMString url); |
|
71 //DOMString isContentHandlerRegistered(DOMString mimeType, DOMString url); |
|
72 //void unregisterProtocolHandler(DOMString scheme, DOMString url); |
|
73 //void unregisterContentHandler(DOMString mimeType, DOMString url); |
|
74 }; |
|
75 |
|
76 [NoInterfaceObject] |
|
77 interface NavigatorStorageUtils { |
|
78 // NOT IMPLEMENTED |
|
79 //void yieldForStorageUpdates(); |
|
80 }; |
|
81 |
|
82 // Things that definitely need to be in the spec and and are not for some |
|
83 // reason. See https://www.w3.org/Bugs/Public/show_bug.cgi?id=22406 |
|
84 partial interface Navigator { |
|
85 [Throws] |
|
86 readonly attribute MimeTypeArray mimeTypes; |
|
87 [Throws] |
|
88 readonly attribute PluginArray plugins; |
|
89 }; |
|
90 |
|
91 // http://www.w3.org/TR/tracking-dnt/ sort of |
|
92 partial interface Navigator { |
|
93 readonly attribute DOMString doNotTrack; |
|
94 }; |
|
95 |
|
96 // http://www.w3.org/TR/geolocation-API/#geolocation_interface |
|
97 [NoInterfaceObject] |
|
98 interface NavigatorGeolocation { |
|
99 [Throws, Pref="geo.enabled"] |
|
100 readonly attribute Geolocation geolocation; |
|
101 }; |
|
102 Navigator implements NavigatorGeolocation; |
|
103 |
|
104 // http://www.w3.org/TR/battery-status/#navigatorbattery-interface |
|
105 [NoInterfaceObject] |
|
106 interface NavigatorBattery { |
|
107 // XXXbz Per spec this should be non-nullable, but we return null in |
|
108 // torn-down windows. See bug 884925. |
|
109 [Throws, Func="Navigator::HasBatterySupport"] |
|
110 readonly attribute BatteryManager? battery; |
|
111 }; |
|
112 Navigator implements NavigatorBattery; |
|
113 |
|
114 // https://wiki.mozilla.org/WebAPI/DataStore |
|
115 [NoInterfaceObject] |
|
116 interface NavigatorDataStore { |
|
117 [Throws, NewObject, Func="Navigator::HasDataStoreSupport"] |
|
118 Promise getDataStores(DOMString name); |
|
119 }; |
|
120 Navigator implements NavigatorDataStore; |
|
121 |
|
122 // http://www.w3.org/TR/vibration/#vibration-interface |
|
123 partial interface Navigator { |
|
124 // We don't support sequences in unions yet |
|
125 //boolean vibrate ((unsigned long or sequence<unsigned long>) pattern); |
|
126 boolean vibrate(unsigned long duration); |
|
127 boolean vibrate(sequence<unsigned long> pattern); |
|
128 }; |
|
129 |
|
130 // http://www.w3.org/TR/pointerevents/#extensions-to-the-navigator-interface |
|
131 partial interface Navigator { |
|
132 [Pref="dom.w3c_pointer_events.enabled"] |
|
133 readonly attribute long maxTouchPoints; |
|
134 }; |
|
135 |
|
136 // Mozilla-specific extensions |
|
137 |
|
138 callback interface MozIdleObserver { |
|
139 // Time is in seconds and is read only when idle observers are added |
|
140 // and removed. |
|
141 readonly attribute unsigned long time; |
|
142 void onidle(); |
|
143 void onactive(); |
|
144 }; |
|
145 |
|
146 // nsIDOMNavigator |
|
147 partial interface Navigator { |
|
148 [Throws] |
|
149 readonly attribute DOMString oscpu; |
|
150 // WebKit/Blink support this; Trident/Presto do not. |
|
151 readonly attribute DOMString vendor; |
|
152 // WebKit/Blink supports this (hardcoded ""); Trident/Presto do not. |
|
153 readonly attribute DOMString vendorSub; |
|
154 // WebKit/Blink supports this (hardcoded "20030107"); Trident/Presto don't |
|
155 readonly attribute DOMString productSub; |
|
156 // WebKit/Blink/Trident/Presto support this. |
|
157 readonly attribute boolean cookieEnabled; |
|
158 [Throws] |
|
159 readonly attribute DOMString buildID; |
|
160 [Throws, Func="Navigator::HasPowerSupport"] |
|
161 readonly attribute MozPowerManager mozPower; |
|
162 |
|
163 // WebKit/Blink/Trident/Presto support this. |
|
164 [Throws] |
|
165 boolean javaEnabled(); |
|
166 |
|
167 /** |
|
168 * Navigator requests to add an idle observer to the existing window. |
|
169 */ |
|
170 [Throws, Func="Navigator::HasIdleSupport"] |
|
171 void addIdleObserver(MozIdleObserver aIdleObserver); |
|
172 |
|
173 /** |
|
174 * Navigator requests to remove an idle observer from the existing window. |
|
175 */ |
|
176 [Throws, Func="Navigator::HasIdleSupport"] |
|
177 void removeIdleObserver(MozIdleObserver aIdleObserver); |
|
178 |
|
179 /** |
|
180 * Request a wake lock for a resource. |
|
181 * |
|
182 * A page holds a wake lock to request that a resource not be turned |
|
183 * off (or otherwise made unavailable). |
|
184 * |
|
185 * The topic is the name of a resource that might be made unavailable for |
|
186 * various reasons. For example, on a mobile device the power manager might |
|
187 * decide to turn off the screen after a period of idle time to save power. |
|
188 * |
|
189 * The resource manager checks the lock state of a topic before turning off |
|
190 * the associated resource. For example, a page could hold a lock on the |
|
191 * "screen" topic to prevent the screensaver from appearing or the screen |
|
192 * from turning off. |
|
193 * |
|
194 * The resource manager defines what each topic means and sets policy. For |
|
195 * example, the resource manager might decide to ignore 'screen' wake locks |
|
196 * held by pages which are not visible. |
|
197 * |
|
198 * One topic can be locked multiple times; it is considered released only when |
|
199 * all locks on the topic have been released. |
|
200 * |
|
201 * The returned MozWakeLock object is a token of the lock. You can |
|
202 * unlock the lock via the object's |unlock| method. The lock is released |
|
203 * automatically when its associated window is unloaded. |
|
204 * |
|
205 * @param aTopic resource name |
|
206 */ |
|
207 [Throws, Pref="dom.wakelock.enabled", Func="Navigator::HasWakeLockSupport"] |
|
208 MozWakeLock requestWakeLock(DOMString aTopic); |
|
209 }; |
|
210 |
|
211 // nsIDOMNavigatorDeviceStorage |
|
212 partial interface Navigator { |
|
213 [Throws, Pref="device.storage.enabled"] |
|
214 DeviceStorage? getDeviceStorage(DOMString type); |
|
215 [Throws, Pref="device.storage.enabled"] |
|
216 sequence<DeviceStorage> getDeviceStorages(DOMString type); |
|
217 }; |
|
218 |
|
219 // nsIDOMNavigatorDesktopNotification |
|
220 partial interface Navigator { |
|
221 [Throws, Func="Navigator::HasDesktopNotificationSupport"] |
|
222 readonly attribute DesktopNotificationCenter mozNotification; |
|
223 }; |
|
224 |
|
225 // nsIDOMClientInformation |
|
226 partial interface Navigator { |
|
227 [Throws] |
|
228 boolean mozIsLocallyAvailable(DOMString uri, boolean whenOffline); |
|
229 }; |
|
230 |
|
231 // nsIDOMMozNavigatorMobileMessage |
|
232 interface MozMobileMessageManager; |
|
233 partial interface Navigator { |
|
234 [Func="Navigator::HasMobileMessageSupport"] |
|
235 readonly attribute MozMobileMessageManager? mozMobileMessage; |
|
236 }; |
|
237 |
|
238 // NetworkInformation |
|
239 partial interface Navigator { |
|
240 [Throws, Pref="dom.netinfo.enabled"] |
|
241 readonly attribute NetworkInformation connection; |
|
242 }; |
|
243 |
|
244 // nsIDOMNavigatorCamera |
|
245 partial interface Navigator { |
|
246 [Throws, Func="Navigator::HasCameraSupport"] |
|
247 readonly attribute CameraManager mozCameras; |
|
248 }; |
|
249 |
|
250 // nsIDOMNavigatorSystemMessages and sort of maybe |
|
251 // http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1 |
|
252 callback systemMessageCallback = void (optional object message); |
|
253 partial interface Navigator { |
|
254 [Throws, Pref="dom.sysmsg.enabled"] |
|
255 void mozSetMessageHandler (DOMString type, systemMessageCallback? callback); |
|
256 [Throws, Pref="dom.sysmsg.enabled"] |
|
257 boolean mozHasPendingMessage (DOMString type); |
|
258 }; |
|
259 |
|
260 #ifdef MOZ_B2G_RIL |
|
261 partial interface Navigator { |
|
262 [Throws, Func="Navigator::HasMobileConnectionSupport"] |
|
263 readonly attribute MozMobileConnectionArray mozMobileConnections; |
|
264 }; |
|
265 |
|
266 partial interface Navigator { |
|
267 [Throws, Func="Navigator::HasCellBroadcastSupport"] |
|
268 readonly attribute MozCellBroadcast mozCellBroadcast; |
|
269 }; |
|
270 |
|
271 partial interface Navigator { |
|
272 [Throws, Func="Navigator::HasVoicemailSupport"] |
|
273 readonly attribute MozVoicemail mozVoicemail; |
|
274 }; |
|
275 |
|
276 partial interface Navigator { |
|
277 [Throws, Func="Navigator::HasIccManagerSupport"] |
|
278 readonly attribute MozIccManager? mozIccManager; |
|
279 }; |
|
280 #endif // MOZ_B2G_RIL |
|
281 |
|
282 partial interface Navigator { |
|
283 [Throws, Func="Navigator::HasTelephonySupport"] |
|
284 readonly attribute Telephony? mozTelephony; |
|
285 }; |
|
286 |
|
287 #ifdef MOZ_GAMEPAD |
|
288 // https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension |
|
289 partial interface Navigator { |
|
290 [Throws, Pref="dom.gamepad.enabled"] |
|
291 sequence<Gamepad?> getGamepads(); |
|
292 }; |
|
293 #endif // MOZ_GAMEPAD |
|
294 |
|
295 #ifdef MOZ_B2G_BT |
|
296 partial interface Navigator { |
|
297 [Throws, Func="Navigator::HasBluetoothSupport"] |
|
298 readonly attribute BluetoothManager mozBluetooth; |
|
299 }; |
|
300 #endif // MOZ_B2G_BT |
|
301 |
|
302 #ifdef MOZ_B2G_FM |
|
303 partial interface Navigator { |
|
304 [Throws, Func="Navigator::HasFMRadioSupport"] |
|
305 readonly attribute FMRadio mozFMRadio; |
|
306 }; |
|
307 #endif // MOZ_B2G_FM |
|
308 |
|
309 #ifdef MOZ_TIME_MANAGER |
|
310 // nsIDOMMozNavigatorTime |
|
311 partial interface Navigator { |
|
312 [Throws, Func="Navigator::HasTimeSupport"] |
|
313 readonly attribute MozTimeManager mozTime; |
|
314 }; |
|
315 #endif // MOZ_TIME_MANAGER |
|
316 |
|
317 #ifdef MOZ_AUDIO_CHANNEL_MANAGER |
|
318 // nsIMozNavigatorAudioChannelManager |
|
319 partial interface Navigator { |
|
320 [Throws] |
|
321 readonly attribute AudioChannelManager mozAudioChannelManager; |
|
322 }; |
|
323 #endif // MOZ_AUDIO_CHANNEL_MANAGER |
|
324 |
|
325 #ifdef MOZ_MEDIA_NAVIGATOR |
|
326 callback NavigatorUserMediaSuccessCallback = void (MediaStream stream); |
|
327 callback NavigatorUserMediaErrorCallback = void (DOMString error); |
|
328 |
|
329 partial interface Navigator { |
|
330 [Throws, Func="Navigator::HasUserMediaSupport"] |
|
331 void mozGetUserMedia(MediaStreamConstraints constraints, |
|
332 NavigatorUserMediaSuccessCallback successCallback, |
|
333 NavigatorUserMediaErrorCallback errorCallback); |
|
334 }; |
|
335 |
|
336 // nsINavigatorUserMedia |
|
337 callback MozGetUserMediaDevicesSuccessCallback = void (nsIVariant? devices); |
|
338 partial interface Navigator { |
|
339 [Throws, ChromeOnly] |
|
340 void mozGetUserMediaDevices(MediaStreamConstraints constraints, |
|
341 MozGetUserMediaDevicesSuccessCallback onsuccess, |
|
342 NavigatorUserMediaErrorCallback onerror, |
|
343 // The originating innerWindowID is needed to |
|
344 // avoid calling the callbacks if the window has |
|
345 // navigated away. It is optional only as legacy. |
|
346 optional unsigned long long innerWindowID = 0); |
|
347 }; |
|
348 #endif // MOZ_MEDIA_NAVIGATOR |
|
349 |
|
350 partial interface Navigator { |
|
351 [Throws, Pref="beacon.enabled"] |
|
352 boolean sendBeacon(DOMString url, |
|
353 optional (ArrayBufferView or Blob or DOMString or FormData)? data = null); |
|
354 }; |