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/.
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
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.
21 // http://www.whatwg.org/specs/web-apps/current-work/#the-navigator-object
22 [HeaderFile="Navigator.h", NeedNewResolve]
24 // objects implementing this interface also implement the interfaces given below
26 Navigator implements NavigatorID;
27 Navigator implements NavigatorLanguage;
28 Navigator implements NavigatorOnLine;
29 Navigator implements NavigatorContentUtils;
30 Navigator implements NavigatorStorageUtils;
31 Navigator implements NavigatorFeatures;
33 [NoInterfaceObject, Exposed=(Window,Worker)]
34 interface NavigatorID {
35 // WebKit/Blink/Trident/Presto support this (hardcoded "Mozilla").
37 readonly attribute DOMString appCodeName; // constant "Mozilla"
39 readonly attribute DOMString appName;
41 readonly attribute DOMString appVersion;
43 readonly attribute DOMString platform;
45 readonly attribute DOMString userAgent;
47 readonly attribute DOMString product; // constant "Gecko"
49 // Everyone but WebKit/Blink supports this. See bug 679971.
50 boolean taintEnabled(); // constant false
54 interface NavigatorLanguage {
56 // These 2 values are cached. They are updated when pref
57 // intl.accept_languages is changed.
60 readonly attribute DOMString? language;
61 [Pure, Cached, Frozen]
62 readonly attribute sequence<DOMString> languages;
65 [NoInterfaceObject, Exposed=(Window,Worker)]
66 interface NavigatorOnLine {
67 readonly attribute boolean onLine;
71 interface NavigatorContentUtils {
72 // content handler registration
74 void registerProtocolHandler(DOMString scheme, DOMString url, DOMString title);
76 void registerContentHandler(DOMString mimeType, DOMString url, DOMString title);
78 //DOMString isProtocolHandlerRegistered(DOMString scheme, DOMString url);
79 //DOMString isContentHandlerRegistered(DOMString mimeType, DOMString url);
80 //void unregisterProtocolHandler(DOMString scheme, DOMString url);
81 //void unregisterContentHandler(DOMString mimeType, DOMString url);
85 interface NavigatorStorageUtils {
87 //void yieldForStorageUpdates();
91 interface NavigatorFeatures {
92 [CheckPermissions="feature-detection", Throws]
93 Promise<any> getFeature(DOMString name);
95 [CheckPermissions="feature-detection", Throws]
96 Promise<any> hasFeature(DOMString name);
99 // Things that definitely need to be in the spec and and are not for some
100 // reason. See https://www.w3.org/Bugs/Public/show_bug.cgi?id=22406
101 partial interface Navigator {
103 readonly attribute MimeTypeArray mimeTypes;
105 readonly attribute PluginArray plugins;
108 // http://www.w3.org/TR/tracking-dnt/ sort of
109 partial interface Navigator {
110 readonly attribute DOMString doNotTrack;
113 // http://www.w3.org/TR/geolocation-API/#geolocation_interface
115 interface NavigatorGeolocation {
116 [Throws, Pref="geo.enabled"]
117 readonly attribute Geolocation geolocation;
119 Navigator implements NavigatorGeolocation;
121 // http://www.w3.org/TR/battery-status/#navigatorbattery-interface
123 interface NavigatorBattery {
124 // XXXbz Per spec this should be non-nullable, but we return null in
125 // torn-down windows. See bug 884925.
126 [Throws, Pref="dom.battery.enabled"]
127 readonly attribute BatteryManager? battery;
129 Navigator implements NavigatorBattery;
131 // https://wiki.mozilla.org/WebAPI/DataStore
133 Exposed=(Window,Worker)]
134 interface NavigatorDataStore {
135 [Throws, NewObject, Func="Navigator::HasDataStoreSupport"]
136 Promise<sequence<DataStore>> getDataStores(DOMString name,
137 optional DOMString? owner = null);
139 Navigator implements NavigatorDataStore;
141 // http://www.w3.org/TR/vibration/#vibration-interface
142 partial interface Navigator {
143 // We don't support sequences in unions yet
144 //boolean vibrate ((unsigned long or sequence<unsigned long>) pattern);
145 boolean vibrate(unsigned long duration);
146 boolean vibrate(sequence<unsigned long> pattern);
149 // http://www.w3.org/TR/pointerevents/#extensions-to-the-navigator-interface
150 partial interface Navigator {
151 [Pref="dom.w3c_pointer_events.enabled"]
152 readonly attribute long maxTouchPoints;
155 // Mozilla-specific extensions
157 callback interface MozIdleObserver {
158 // Time is in seconds and is read only when idle observers are added
160 readonly attribute unsigned long time;
166 dictionary MobileIdOptions {
167 boolean forceSelection = false;
171 interface NavigatorMobileId {
172 // Ideally we would use [CheckPermissions] here, but the "mobileid"
173 // permission is set to PROMPT_ACTION and [CheckPermissions] only checks
175 // XXXbz what is this promise resolved with?
176 [Throws, NewObject, Func="Navigator::HasMobileIdSupport"]
177 Promise<any> getMobileIdAssertion(optional MobileIdOptions options);
179 Navigator implements NavigatorMobileId;
183 partial interface Navigator {
185 readonly attribute DOMString oscpu;
186 // WebKit/Blink support this; Trident/Presto do not.
187 readonly attribute DOMString vendor;
188 // WebKit/Blink supports this (hardcoded ""); Trident/Presto do not.
189 readonly attribute DOMString vendorSub;
190 // WebKit/Blink supports this (hardcoded "20030107"); Trident/Presto don't
191 readonly attribute DOMString productSub;
192 // WebKit/Blink/Trident/Presto support this.
193 readonly attribute boolean cookieEnabled;
195 readonly attribute DOMString buildID;
196 [Throws, CheckPermissions="power"]
197 readonly attribute MozPowerManager mozPower;
199 // WebKit/Blink/Trident/Presto support this.
201 boolean javaEnabled();
204 * Navigator requests to add an idle observer to the existing window.
206 [Throws, CheckPermissions="idle"]
207 void addIdleObserver(MozIdleObserver aIdleObserver);
210 * Navigator requests to remove an idle observer from the existing window.
212 [Throws, CheckPermissions="idle"]
213 void removeIdleObserver(MozIdleObserver aIdleObserver);
216 * Request a wake lock for a resource.
218 * A page holds a wake lock to request that a resource not be turned
219 * off (or otherwise made unavailable).
221 * The topic is the name of a resource that might be made unavailable for
222 * various reasons. For example, on a mobile device the power manager might
223 * decide to turn off the screen after a period of idle time to save power.
225 * The resource manager checks the lock state of a topic before turning off
226 * the associated resource. For example, a page could hold a lock on the
227 * "screen" topic to prevent the screensaver from appearing or the screen
230 * The resource manager defines what each topic means and sets policy. For
231 * example, the resource manager might decide to ignore 'screen' wake locks
232 * held by pages which are not visible.
234 * One topic can be locked multiple times; it is considered released only when
235 * all locks on the topic have been released.
237 * The returned MozWakeLock object is a token of the lock. You can
238 * unlock the lock via the object's |unlock| method. The lock is released
239 * automatically when its associated window is unloaded.
241 * @param aTopic resource name
243 [Throws, Pref="dom.wakelock.enabled", Func="Navigator::HasWakeLockSupport"]
244 MozWakeLock requestWakeLock(DOMString aTopic);
247 // nsIDOMNavigatorDeviceStorage
248 partial interface Navigator {
249 [Throws, Pref="device.storage.enabled"]
250 DeviceStorage? getDeviceStorage(DOMString type);
251 [Throws, Pref="device.storage.enabled"]
252 sequence<DeviceStorage> getDeviceStorages(DOMString type);
255 // nsIDOMNavigatorDesktopNotification
256 partial interface Navigator {
257 [Throws, Pref="notification.feature.enabled"]
258 readonly attribute DesktopNotificationCenter mozNotification;
261 // nsIDOMClientInformation
262 partial interface Navigator {
264 boolean mozIsLocallyAvailable(DOMString uri, boolean whenOffline);
267 #ifdef MOZ_WEBSMS_BACKEND
268 partial interface Navigator {
269 [CheckPermissions="sms", Pref="dom.sms.enabled"]
270 readonly attribute MozMobileMessageManager? mozMobileMessage;
274 // NetworkInformation
275 partial interface Navigator {
276 [Throws, Pref="dom.netinfo.enabled"]
277 readonly attribute NetworkInformation connection;
280 // nsIDOMNavigatorCamera
281 partial interface Navigator {
282 [Throws, Func="Navigator::HasCameraSupport"]
283 readonly attribute CameraManager mozCameras;
286 // nsIDOMNavigatorSystemMessages and sort of maybe
287 // http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1
288 callback systemMessageCallback = void (optional object message);
289 partial interface Navigator {
290 [Throws, Pref="dom.sysmsg.enabled"]
291 void mozSetMessageHandler (DOMString type, systemMessageCallback? callback);
292 [Throws, Pref="dom.sysmsg.enabled"]
293 boolean mozHasPendingMessage (DOMString type);
297 partial interface Navigator {
298 [Throws, Pref="dom.mobileconnection.enabled", CheckPermissions="mobileconnection mobilenetwork"]
299 readonly attribute MozMobileConnectionArray mozMobileConnections;
302 partial interface Navigator {
303 [Throws, Pref="dom.cellbroadcast.enabled", CheckPermissions="cellbroadcast"]
304 readonly attribute MozCellBroadcast mozCellBroadcast;
307 partial interface Navigator {
308 [Throws, Pref="dom.voicemail.enabled", CheckPermissions="voicemail"]
309 readonly attribute MozVoicemail mozVoicemail;
312 partial interface Navigator {
313 [Throws, Pref="dom.icc.enabled", CheckPermissions="mobileconnection"]
314 readonly attribute MozIccManager? mozIccManager;
317 partial interface Navigator {
318 [Throws, Pref="dom.telephony.enabled", CheckPermissions="telephony"]
319 readonly attribute Telephony? mozTelephony;
321 #endif // MOZ_B2G_RIL
324 // https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension
325 partial interface Navigator {
326 [Throws, Pref="dom.gamepad.enabled"]
327 sequence<Gamepad?> getGamepads();
329 #endif // MOZ_GAMEPAD
332 partial interface Navigator {
333 [Throws, CheckPermissions="bluetooth"]
334 readonly attribute BluetoothManager mozBluetooth;
339 partial interface Navigator {
340 [Throws, CheckPermissions="fmradio"]
341 readonly attribute FMRadio mozFMRadio;
345 #ifdef MOZ_TIME_MANAGER
346 // nsIDOMMozNavigatorTime
347 partial interface Navigator {
348 [Throws, CheckPermissions="time"]
349 readonly attribute MozTimeManager mozTime;
351 #endif // MOZ_TIME_MANAGER
353 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
354 // nsIMozNavigatorAudioChannelManager
355 partial interface Navigator {
357 readonly attribute AudioChannelManager mozAudioChannelManager;
359 #endif // MOZ_AUDIO_CHANNEL_MANAGER
361 #ifdef MOZ_MEDIA_NAVIGATOR
362 callback NavigatorUserMediaSuccessCallback = void (MediaStream stream);
363 callback NavigatorUserMediaErrorCallback = void (DOMString error);
365 partial interface Navigator {
366 [Throws, Func="Navigator::HasUserMediaSupport"]
367 void mozGetUserMedia(MediaStreamConstraints constraints,
368 NavigatorUserMediaSuccessCallback successCallback,
369 NavigatorUserMediaErrorCallback errorCallback);
372 // nsINavigatorUserMedia
373 callback MozGetUserMediaDevicesSuccessCallback = void (nsIVariant? devices);
374 partial interface Navigator {
376 void mozGetUserMediaDevices(MediaStreamConstraints constraints,
377 MozGetUserMediaDevicesSuccessCallback onsuccess,
378 NavigatorUserMediaErrorCallback onerror,
379 // The originating innerWindowID is needed to
380 // avoid calling the callbacks if the window has
381 // navigated away. It is optional only as legacy.
382 optional unsigned long long innerWindowID = 0);
384 #endif // MOZ_MEDIA_NAVIGATOR
386 // Service Workers/Navigation Controllers
387 partial interface Navigator {
388 [Pref="dom.serviceWorkers.enabled"]
389 readonly attribute ServiceWorkerContainer serviceWorker;
392 partial interface Navigator {
393 [Throws, Pref="beacon.enabled"]
394 boolean sendBeacon(DOMString url,
395 optional (ArrayBufferView or Blob or DOMString or FormData)? data = null);