michael@0: /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: * michael@0: * The origin of this IDL file is michael@0: * http://www.whatwg.org/specs/web-apps/current-work/#the-navigator-object michael@0: * http://www.w3.org/TR/tracking-dnt/ michael@0: * http://www.w3.org/TR/geolocation-API/#geolocation_interface michael@0: * http://www.w3.org/TR/battery-status/#navigatorbattery-interface michael@0: * http://www.w3.org/TR/vibration/#vibration-interface michael@0: * http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1 michael@0: * https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension michael@0: * http://www.w3.org/TR/beacon/#sec-beacon-method michael@0: * michael@0: * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and michael@0: * Opera Software ASA. You are granted a license to use, reproduce michael@0: * and create derivative works of this document. michael@0: */ michael@0: michael@0: // http://www.whatwg.org/specs/web-apps/current-work/#the-navigator-object michael@0: [HeaderFile="Navigator.h", NeedNewResolve] michael@0: interface Navigator { michael@0: // objects implementing this interface also implement the interfaces given below michael@0: }; michael@0: Navigator implements NavigatorID; michael@0: Navigator implements NavigatorLanguage; michael@0: Navigator implements NavigatorOnLine; michael@0: Navigator implements NavigatorContentUtils; michael@0: Navigator implements NavigatorStorageUtils; michael@0: michael@0: [NoInterfaceObject] michael@0: interface NavigatorID { michael@0: // WebKit/Blink/Trident/Presto support this (hardcoded "Mozilla"). michael@0: [Constant] michael@0: readonly attribute DOMString appCodeName; // constant "Mozilla" michael@0: [Constant] michael@0: readonly attribute DOMString appName; michael@0: [Constant] michael@0: readonly attribute DOMString appVersion; michael@0: [Constant] michael@0: readonly attribute DOMString platform; michael@0: [Constant] michael@0: readonly attribute DOMString userAgent; michael@0: [Constant] michael@0: readonly attribute DOMString product; // constant "Gecko" michael@0: michael@0: // Everyone but WebKit/Blink supports this. See bug 679971. michael@0: boolean taintEnabled(); // constant false michael@0: }; michael@0: michael@0: [NoInterfaceObject] michael@0: interface NavigatorLanguage { michael@0: readonly attribute DOMString? language; michael@0: }; michael@0: michael@0: [NoInterfaceObject] michael@0: interface NavigatorOnLine { michael@0: readonly attribute boolean onLine; michael@0: }; michael@0: michael@0: [NoInterfaceObject] michael@0: interface NavigatorContentUtils { michael@0: // content handler registration michael@0: [Throws] michael@0: void registerProtocolHandler(DOMString scheme, DOMString url, DOMString title); michael@0: [Throws] michael@0: void registerContentHandler(DOMString mimeType, DOMString url, DOMString title); michael@0: // NOT IMPLEMENTED michael@0: //DOMString isProtocolHandlerRegistered(DOMString scheme, DOMString url); michael@0: //DOMString isContentHandlerRegistered(DOMString mimeType, DOMString url); michael@0: //void unregisterProtocolHandler(DOMString scheme, DOMString url); michael@0: //void unregisterContentHandler(DOMString mimeType, DOMString url); michael@0: }; michael@0: michael@0: [NoInterfaceObject] michael@0: interface NavigatorStorageUtils { michael@0: // NOT IMPLEMENTED michael@0: //void yieldForStorageUpdates(); michael@0: }; michael@0: michael@0: // Things that definitely need to be in the spec and and are not for some michael@0: // reason. See https://www.w3.org/Bugs/Public/show_bug.cgi?id=22406 michael@0: partial interface Navigator { michael@0: [Throws] michael@0: readonly attribute MimeTypeArray mimeTypes; michael@0: [Throws] michael@0: readonly attribute PluginArray plugins; michael@0: }; michael@0: michael@0: // http://www.w3.org/TR/tracking-dnt/ sort of michael@0: partial interface Navigator { michael@0: readonly attribute DOMString doNotTrack; michael@0: }; michael@0: michael@0: // http://www.w3.org/TR/geolocation-API/#geolocation_interface michael@0: [NoInterfaceObject] michael@0: interface NavigatorGeolocation { michael@0: [Throws, Pref="geo.enabled"] michael@0: readonly attribute Geolocation geolocation; michael@0: }; michael@0: Navigator implements NavigatorGeolocation; michael@0: michael@0: // http://www.w3.org/TR/battery-status/#navigatorbattery-interface michael@0: [NoInterfaceObject] michael@0: interface NavigatorBattery { michael@0: // XXXbz Per spec this should be non-nullable, but we return null in michael@0: // torn-down windows. See bug 884925. michael@0: [Throws, Func="Navigator::HasBatterySupport"] michael@0: readonly attribute BatteryManager? battery; michael@0: }; michael@0: Navigator implements NavigatorBattery; michael@0: michael@0: // https://wiki.mozilla.org/WebAPI/DataStore michael@0: [NoInterfaceObject] michael@0: interface NavigatorDataStore { michael@0: [Throws, NewObject, Func="Navigator::HasDataStoreSupport"] michael@0: Promise getDataStores(DOMString name); michael@0: }; michael@0: Navigator implements NavigatorDataStore; michael@0: michael@0: // http://www.w3.org/TR/vibration/#vibration-interface michael@0: partial interface Navigator { michael@0: // We don't support sequences in unions yet michael@0: //boolean vibrate ((unsigned long or sequence) pattern); michael@0: boolean vibrate(unsigned long duration); michael@0: boolean vibrate(sequence pattern); michael@0: }; michael@0: michael@0: // http://www.w3.org/TR/pointerevents/#extensions-to-the-navigator-interface michael@0: partial interface Navigator { michael@0: [Pref="dom.w3c_pointer_events.enabled"] michael@0: readonly attribute long maxTouchPoints; michael@0: }; michael@0: michael@0: // Mozilla-specific extensions michael@0: michael@0: callback interface MozIdleObserver { michael@0: // Time is in seconds and is read only when idle observers are added michael@0: // and removed. michael@0: readonly attribute unsigned long time; michael@0: void onidle(); michael@0: void onactive(); michael@0: }; michael@0: michael@0: // nsIDOMNavigator michael@0: partial interface Navigator { michael@0: [Throws] michael@0: readonly attribute DOMString oscpu; michael@0: // WebKit/Blink support this; Trident/Presto do not. michael@0: readonly attribute DOMString vendor; michael@0: // WebKit/Blink supports this (hardcoded ""); Trident/Presto do not. michael@0: readonly attribute DOMString vendorSub; michael@0: // WebKit/Blink supports this (hardcoded "20030107"); Trident/Presto don't michael@0: readonly attribute DOMString productSub; michael@0: // WebKit/Blink/Trident/Presto support this. michael@0: readonly attribute boolean cookieEnabled; michael@0: [Throws] michael@0: readonly attribute DOMString buildID; michael@0: [Throws, Func="Navigator::HasPowerSupport"] michael@0: readonly attribute MozPowerManager mozPower; michael@0: michael@0: // WebKit/Blink/Trident/Presto support this. michael@0: [Throws] michael@0: boolean javaEnabled(); michael@0: michael@0: /** michael@0: * Navigator requests to add an idle observer to the existing window. michael@0: */ michael@0: [Throws, Func="Navigator::HasIdleSupport"] michael@0: void addIdleObserver(MozIdleObserver aIdleObserver); michael@0: michael@0: /** michael@0: * Navigator requests to remove an idle observer from the existing window. michael@0: */ michael@0: [Throws, Func="Navigator::HasIdleSupport"] michael@0: void removeIdleObserver(MozIdleObserver aIdleObserver); michael@0: michael@0: /** michael@0: * Request a wake lock for a resource. michael@0: * michael@0: * A page holds a wake lock to request that a resource not be turned michael@0: * off (or otherwise made unavailable). michael@0: * michael@0: * The topic is the name of a resource that might be made unavailable for michael@0: * various reasons. For example, on a mobile device the power manager might michael@0: * decide to turn off the screen after a period of idle time to save power. michael@0: * michael@0: * The resource manager checks the lock state of a topic before turning off michael@0: * the associated resource. For example, a page could hold a lock on the michael@0: * "screen" topic to prevent the screensaver from appearing or the screen michael@0: * from turning off. michael@0: * michael@0: * The resource manager defines what each topic means and sets policy. For michael@0: * example, the resource manager might decide to ignore 'screen' wake locks michael@0: * held by pages which are not visible. michael@0: * michael@0: * One topic can be locked multiple times; it is considered released only when michael@0: * all locks on the topic have been released. michael@0: * michael@0: * The returned MozWakeLock object is a token of the lock. You can michael@0: * unlock the lock via the object's |unlock| method. The lock is released michael@0: * automatically when its associated window is unloaded. michael@0: * michael@0: * @param aTopic resource name michael@0: */ michael@0: [Throws, Pref="dom.wakelock.enabled", Func="Navigator::HasWakeLockSupport"] michael@0: MozWakeLock requestWakeLock(DOMString aTopic); michael@0: }; michael@0: michael@0: // nsIDOMNavigatorDeviceStorage michael@0: partial interface Navigator { michael@0: [Throws, Pref="device.storage.enabled"] michael@0: DeviceStorage? getDeviceStorage(DOMString type); michael@0: [Throws, Pref="device.storage.enabled"] michael@0: sequence getDeviceStorages(DOMString type); michael@0: }; michael@0: michael@0: // nsIDOMNavigatorDesktopNotification michael@0: partial interface Navigator { michael@0: [Throws, Func="Navigator::HasDesktopNotificationSupport"] michael@0: readonly attribute DesktopNotificationCenter mozNotification; michael@0: }; michael@0: michael@0: // nsIDOMClientInformation michael@0: partial interface Navigator { michael@0: [Throws] michael@0: boolean mozIsLocallyAvailable(DOMString uri, boolean whenOffline); michael@0: }; michael@0: michael@0: // nsIDOMMozNavigatorMobileMessage michael@0: interface MozMobileMessageManager; michael@0: partial interface Navigator { michael@0: [Func="Navigator::HasMobileMessageSupport"] michael@0: readonly attribute MozMobileMessageManager? mozMobileMessage; michael@0: }; michael@0: michael@0: // NetworkInformation michael@0: partial interface Navigator { michael@0: [Throws, Pref="dom.netinfo.enabled"] michael@0: readonly attribute NetworkInformation connection; michael@0: }; michael@0: michael@0: // nsIDOMNavigatorCamera michael@0: partial interface Navigator { michael@0: [Throws, Func="Navigator::HasCameraSupport"] michael@0: readonly attribute CameraManager mozCameras; michael@0: }; michael@0: michael@0: // nsIDOMNavigatorSystemMessages and sort of maybe michael@0: // http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1 michael@0: callback systemMessageCallback = void (optional object message); michael@0: partial interface Navigator { michael@0: [Throws, Pref="dom.sysmsg.enabled"] michael@0: void mozSetMessageHandler (DOMString type, systemMessageCallback? callback); michael@0: [Throws, Pref="dom.sysmsg.enabled"] michael@0: boolean mozHasPendingMessage (DOMString type); michael@0: }; michael@0: michael@0: #ifdef MOZ_B2G_RIL michael@0: partial interface Navigator { michael@0: [Throws, Func="Navigator::HasMobileConnectionSupport"] michael@0: readonly attribute MozMobileConnectionArray mozMobileConnections; michael@0: }; michael@0: michael@0: partial interface Navigator { michael@0: [Throws, Func="Navigator::HasCellBroadcastSupport"] michael@0: readonly attribute MozCellBroadcast mozCellBroadcast; michael@0: }; michael@0: michael@0: partial interface Navigator { michael@0: [Throws, Func="Navigator::HasVoicemailSupport"] michael@0: readonly attribute MozVoicemail mozVoicemail; michael@0: }; michael@0: michael@0: partial interface Navigator { michael@0: [Throws, Func="Navigator::HasIccManagerSupport"] michael@0: readonly attribute MozIccManager? mozIccManager; michael@0: }; michael@0: #endif // MOZ_B2G_RIL michael@0: michael@0: partial interface Navigator { michael@0: [Throws, Func="Navigator::HasTelephonySupport"] michael@0: readonly attribute Telephony? mozTelephony; michael@0: }; michael@0: michael@0: #ifdef MOZ_GAMEPAD michael@0: // https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension michael@0: partial interface Navigator { michael@0: [Throws, Pref="dom.gamepad.enabled"] michael@0: sequence getGamepads(); michael@0: }; michael@0: #endif // MOZ_GAMEPAD michael@0: michael@0: #ifdef MOZ_B2G_BT michael@0: partial interface Navigator { michael@0: [Throws, Func="Navigator::HasBluetoothSupport"] michael@0: readonly attribute BluetoothManager mozBluetooth; michael@0: }; michael@0: #endif // MOZ_B2G_BT michael@0: michael@0: #ifdef MOZ_B2G_FM michael@0: partial interface Navigator { michael@0: [Throws, Func="Navigator::HasFMRadioSupport"] michael@0: readonly attribute FMRadio mozFMRadio; michael@0: }; michael@0: #endif // MOZ_B2G_FM michael@0: michael@0: #ifdef MOZ_TIME_MANAGER michael@0: // nsIDOMMozNavigatorTime michael@0: partial interface Navigator { michael@0: [Throws, Func="Navigator::HasTimeSupport"] michael@0: readonly attribute MozTimeManager mozTime; michael@0: }; michael@0: #endif // MOZ_TIME_MANAGER michael@0: michael@0: #ifdef MOZ_AUDIO_CHANNEL_MANAGER michael@0: // nsIMozNavigatorAudioChannelManager michael@0: partial interface Navigator { michael@0: [Throws] michael@0: readonly attribute AudioChannelManager mozAudioChannelManager; michael@0: }; michael@0: #endif // MOZ_AUDIO_CHANNEL_MANAGER michael@0: michael@0: #ifdef MOZ_MEDIA_NAVIGATOR michael@0: callback NavigatorUserMediaSuccessCallback = void (MediaStream stream); michael@0: callback NavigatorUserMediaErrorCallback = void (DOMString error); michael@0: michael@0: partial interface Navigator { michael@0: [Throws, Func="Navigator::HasUserMediaSupport"] michael@0: void mozGetUserMedia(MediaStreamConstraints constraints, michael@0: NavigatorUserMediaSuccessCallback successCallback, michael@0: NavigatorUserMediaErrorCallback errorCallback); michael@0: }; michael@0: michael@0: // nsINavigatorUserMedia michael@0: callback MozGetUserMediaDevicesSuccessCallback = void (nsIVariant? devices); michael@0: partial interface Navigator { michael@0: [Throws, ChromeOnly] michael@0: void mozGetUserMediaDevices(MediaStreamConstraints constraints, michael@0: MozGetUserMediaDevicesSuccessCallback onsuccess, michael@0: NavigatorUserMediaErrorCallback onerror, michael@0: // The originating innerWindowID is needed to michael@0: // avoid calling the callbacks if the window has michael@0: // navigated away. It is optional only as legacy. michael@0: optional unsigned long long innerWindowID = 0); michael@0: }; michael@0: #endif // MOZ_MEDIA_NAVIGATOR michael@0: michael@0: partial interface Navigator { michael@0: [Throws, Pref="beacon.enabled"] michael@0: boolean sendBeacon(DOMString url, michael@0: optional (ArrayBufferView or Blob or DOMString or FormData)? data = null); michael@0: };