From d665c0e1a51e7d19d94fc1a768d8786501e06d26 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 12 Jul 2013 10:35:44 -0400 Subject: [PATCH] Bug 838146 part 2. Implement WebIDL API on Navigator for all our nonstandard extensions that are not behind build-time flags. r=smaug, sr=peterv --- dom/base/Navigator.cpp | 266 +++++++++++++++++++++------ dom/base/Navigator.h | 34 ++++ dom/bindings/Bindings.conf | 3 + dom/camera/DOMCameraManager.cpp | 16 +- dom/camera/DOMCameraManager.h | 3 +- dom/media/MediaManager.cpp | 6 +- dom/mobilemessage/src/SmsManager.cpp | 24 ++- dom/mobilemessage/src/SmsManager.h | 5 +- dom/webidl/Navigator.webidl | 57 ++++++ 9 files changed, 335 insertions(+), 79 deletions(-) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index c50c44ab5600..cfccb9663dc4 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -1099,8 +1099,19 @@ NS_IMETHODIMP Navigator::GetDeviceStorage(const nsAString &aType, nsIDOMDeviceSt return NS_OK; } + ErrorResult rv; + NS_IF_ADDREF(*_retval = GetDeviceStorage(aType, rv)); + return rv.ErrorCode(); +} + +nsDOMDeviceStorage* +Navigator::GetDeviceStorage(const nsAString& aType, ErrorResult& aRv) +{ + // Callers (either the XPCOM method or the WebIDL binding) are responsible for + // the pref check here. if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { - return NS_ERROR_FAILURE; + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; } nsRefPtr storage; @@ -1108,12 +1119,11 @@ NS_IMETHODIMP Navigator::GetDeviceStorage(const nsAString &aType, nsIDOMDeviceSt getter_AddRefs(storage)); if (!storage) { - return NS_OK; + return nullptr; } - NS_ADDREF(*_retval = storage.get()); mDeviceStorageStores.AppendElement(storage); - return NS_OK; + return storage; } NS_IMETHODIMP Navigator::GetDeviceStorages(const nsAString &aType, nsIVariant** _retval) @@ -1125,12 +1135,12 @@ NS_IMETHODIMP Navigator::GetDeviceStorages(const nsAString &aType, nsIVariant** return NS_OK; } - if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { - return NS_ERROR_FAILURE; - } - nsTArray > stores; - nsDOMDeviceStorage::CreateDeviceStoragesFor(mWindow, aType, stores, false); + ErrorResult rv; + GetDeviceStorages(aType, stores, rv); + if (rv.Failed()) { + return rv.ErrorCode(); + } nsCOMPtr result = do_CreateInstance("@mozilla.org/variant;1"); NS_ENSURE_TRUE(result, NS_ERROR_FAILURE); @@ -1145,10 +1155,26 @@ NS_IMETHODIMP Navigator::GetDeviceStorages(const nsAString &aType, nsIVariant** } result.forget(_retval); - mDeviceStorageStores.AppendElements(stores); return NS_OK; } +void +Navigator::GetDeviceStorages(const nsAString& aType, + nsTArray >& aStores, + ErrorResult& aRv) +{ + // Callers (either the XPCOM method or the WebIDL binding) are responsible for + // the pref check here. + if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { + aRv.Throw(NS_ERROR_FAILURE); + return; + } + + nsDOMDeviceStorage::CreateDeviceStoragesFor(mWindow, aType, aStores, false); + + mDeviceStorageStores.AppendElements(aStores); +} + //***************************************************************************** // Navigator::nsIDOMNavigatorGeolocation //***************************************************************************** @@ -1241,20 +1267,25 @@ Navigator::MozGetUserMediaDevices(nsIGetUserMediaDevicesSuccessCallback* aOnSucc NS_IMETHODIMP Navigator::GetMozNotification(nsISupports** aRetVal) { - NS_ENSURE_ARG_POINTER(aRetVal); - *aRetVal = nullptr; + ErrorResult rv; + NS_IF_ADDREF(*aRetVal = GetMozNotification(rv)); + return rv.ErrorCode(); +} +DesktopNotificationCenter* +Navigator::GetMozNotification(ErrorResult& aRv) +{ if (mNotification) { - NS_ADDREF(*aRetVal = mNotification); - return NS_OK; + return mNotification; } - NS_ENSURE_TRUE(mWindow && mWindow->GetDocShell(), NS_ERROR_FAILURE); + if (!mWindow || !mWindow->GetDocShell()) { + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; + } mNotification = new DesktopNotificationCenter(mWindow); - - NS_ADDREF(*aRetVal = mNotification); - return NS_OK; + return mNotification; } //***************************************************************************** @@ -1352,21 +1383,32 @@ Navigator::RequestWakeLock(const nsAString &aTopic, ErrorResult& aRv) NS_IMETHODIMP Navigator::GetMozSms(nsIDOMMozSmsManager** aSmsManager) { - *aSmsManager = nullptr; - if (!mSmsManager) { - NS_ENSURE_STATE(mWindow); - NS_ENSURE_TRUE(mWindow->GetDocShell(), NS_OK); - - mSmsManager = SmsManager::CreateInstanceIfAllowed(mWindow); - NS_ENSURE_TRUE(mSmsManager, NS_OK); + if (!mWindow || !SmsManager::CreationIsAllowed(mWindow)) { + *aSmsManager = nullptr; + return NS_OK; + } } - NS_ADDREF(*aSmsManager = mSmsManager); - + NS_IF_ADDREF(*aSmsManager = GetMozSms()); return NS_OK; } +nsIDOMMozSmsManager* +Navigator::GetMozSms() +{ + // Callers (either the XPCOM method or the WebIDL binding) are responsible for + // the permission check here. + if (!mSmsManager) { + NS_ENSURE_TRUE(mWindow, nullptr); + NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr); + + mSmsManager = SmsManager::CreateInstance(mWindow); + } + + return mSmsManager; +} + //***************************************************************************** // Navigator::nsIDOMNavigatorMobileMessage //***************************************************************************** @@ -1374,32 +1416,30 @@ Navigator::GetMozSms(nsIDOMMozSmsManager** aSmsManager) NS_IMETHODIMP Navigator::GetMozMobileMessage(nsIDOMMozMobileMessageManager** aMobileMessageManager) { - *aMobileMessageManager = nullptr; + if (!HasMobileMessageSupport(mWindow)) { + *aMobileMessageManager = nullptr; + return NS_OK; + } -#ifndef MOZ_WEBSMS_BACKEND + NS_IF_ADDREF(*aMobileMessageManager = GetMozMobileMessage()); return NS_OK; -#endif - - // First of all, the general pref has to be turned on. - bool enabled = false; - Preferences::GetBool("dom.sms.enabled", &enabled); - NS_ENSURE_TRUE(enabled, NS_OK); +} +nsIDOMMozMobileMessageManager* +Navigator::GetMozMobileMessage() +{ + // Callers (either the XPCOM method or the WebIDL binding) are responsible for + // the permission check here. if (!mMobileMessageManager) { - NS_ENSURE_STATE(mWindow); - NS_ENSURE_TRUE(mWindow->GetDocShell(), NS_OK); - - if (!CheckPermission("sms")) { - return NS_OK; - } + // Check that our window has not gone away + NS_ENSURE_TRUE(mWindow, nullptr); + NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr); mMobileMessageManager = new MobileMessageManager(); mMobileMessageManager->Init(mWindow); } - NS_ADDREF(*aMobileMessageManager = mMobileMessageManager); - - return NS_OK; + return mMobileMessageManager; } #ifdef MOZ_B2G_RIL @@ -1543,18 +1583,22 @@ Navigator::GetGamepads(nsIVariant** aRetVal) NS_IMETHODIMP Navigator::GetMozConnection(nsIDOMMozConnection** aConnection) { - *aConnection = nullptr; + NS_IF_ADDREF(*aConnection = GetMozConnection()); + return NS_OK; +} +nsIDOMMozConnection* +Navigator::GetMozConnection() +{ if (!mConnection) { - NS_ENSURE_STATE(mWindow); - NS_ENSURE_TRUE(mWindow->GetDocShell(), NS_OK); + NS_ENSURE_TRUE(mWindow, nullptr); + NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr); mConnection = new network::Connection(); mConnection->Init(mWindow); } - NS_ADDREF(*aConnection = mConnection); - return NS_OK; + return mConnection; } #ifdef MOZ_B2G_RIL @@ -1643,11 +1687,28 @@ Navigator::MozHasPendingMessage(const nsAString& aType, bool *aResult) return NS_ERROR_NOT_IMPLEMENTED; } - *aResult = false; - nsresult rv = EnsureMessagesManager(); - NS_ENSURE_SUCCESS(rv, rv); + ErrorResult rv; + *aResult = MozHasPendingMessage(aType, rv); + return rv.ErrorCode(); +} - return mMessagesManager->MozHasPendingMessage(aType, aResult); +bool +Navigator::MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv) +{ + // The WebIDL binding is responsible for the pref check here. + nsresult rv = EnsureMessagesManager(); + if (NS_FAILED(rv)) { + aRv.Throw(rv); + return false; + } + + bool result = false; + rv = mMessagesManager->MozHasPendingMessage(aType, &result); + if (NS_FAILED(rv)) { + aRv.Throw(rv); + return false; + } + return result; } NS_IMETHODIMP @@ -1664,6 +1725,28 @@ Navigator::MozSetMessageHandler(const nsAString& aType, return mMessagesManager->MozSetMessageHandler(aType, aCallback); } +void +Navigator::MozSetMessageHandler(const nsAString& aType, + systemMessageCallback* aCallback, + ErrorResult& aRv) +{ + // The WebIDL binding is responsible for the pref check here. + nsresult rv = EnsureMessagesManager(); + if (NS_FAILED(rv)) { + aRv.Throw(rv); + return; + } + + CallbackObjectHolder + holder(aCallback); + nsCOMPtr callback = holder.ToXPCOMCallback(); + + rv = mMessagesManager->MozSetMessageHandler(aType, callback); + if (NS_FAILED(rv)) { + aRv.Throw(rv); + } +} + //***************************************************************************** // Navigator::nsIDOMNavigatorTime //***************************************************************************** @@ -1694,22 +1777,36 @@ Navigator::GetMozTime(nsISupports** aTime) NS_IMETHODIMP Navigator::GetMozCameras(nsISupports** aCameraManager) { + if (!mCameraManager) { + NS_ENSURE_STATE(mWindow); + if (!nsDOMCameraManager::CheckPermission(mWindow)) { + *aCameraManager = nullptr; + return NS_OK; + } + } + + ErrorResult rv; + NS_IF_ADDREF(*aCameraManager = static_cast(GetMozCameras(rv))); + return rv.ErrorCode(); +} + +nsDOMCameraManager* +Navigator::GetMozCameras(ErrorResult& aRv) +{ + // Callers (either the XPCOM method or the WebIDL binding) are responsible for + // the permission check here. if (!mCameraManager) { if (!mWindow || !mWindow->GetOuterWindow() || mWindow->GetOuterWindow()->GetCurrentInnerWindow() != mWindow) { - return NS_ERROR_NOT_AVAILABLE; + aRv.Throw(NS_ERROR_NOT_AVAILABLE); + return nullptr; } - mCameraManager = - nsDOMCameraManager::CheckPermissionAndCreateInstance(mWindow); - NS_ENSURE_TRUE(mCameraManager, NS_OK); + mCameraManager = nsDOMCameraManager::CreateInstance(mWindow); } - nsCOMPtr cameraManager = mCameraManager.get(); - cameraManager.forget(aCameraManager); - - return NS_OK; + return mCameraManager; } size_t @@ -1832,6 +1929,53 @@ Navigator::HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */) return !!pmService; } +/* static */ +bool +Navigator::HasSmsSupport(JSContext* /* unused */, JSObject* aGlobal) +{ + nsCOMPtr win = GetWindowFromGlobal(aGlobal); + return win && SmsManager::CreationIsAllowed(win); +} + +/* static */ +bool +Navigator::HasMobileMessageSupport(JSContext* /* unused */, JSObject* aGlobal) +{ + nsCOMPtr win = GetWindowFromGlobal(aGlobal); + return HasMobileMessageSupport(win); +} + +/* static */ +bool +Navigator::HasMobileMessageSupport(nsPIDOMWindow* aWindow) +{ +#ifndef MOZ_WEBSMS_BACKEND + return false; +#endif + + // First of all, the general pref has to be turned on. + bool enabled = false; + Preferences::GetBool("dom.sms.enabled", &enabled); + NS_ENSURE_TRUE(enabled, false); + + NS_ENSURE_TRUE(aWindow, false); + NS_ENSURE_TRUE(aWindow->GetDocShell(), false); + + if (!CheckPermission(aWindow, "sms")) { + return false; + } + + return true; +} + +/* static */ +bool +Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal) +{ + nsCOMPtr win = GetWindowFromGlobal(aGlobal); + return win && nsDOMCameraManager::CheckPermission(win); +} + /* static */ already_AddRefed Navigator::GetWindowFromGlobal(JSObject* aGlobal) diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 4b6c220b8346..8e6801e18779 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -40,6 +40,7 @@ class nsIDOMMozConnection; namespace mozilla { namespace dom { class Geolocation; +class systemMessageCallback; } } @@ -284,12 +285,44 @@ public: void RemoveIdleObserver(MozIdleObserver& aObserver, ErrorResult& aRv); already_AddRefed RequestWakeLock(const nsAString &aTopic, ErrorResult& aRv); + nsDOMDeviceStorage* GetDeviceStorage(const nsAString& aType, + ErrorResult& aRv); + void GetDeviceStorages(const nsAString& aType, + nsTArray >& aStores, + ErrorResult& aRv); + DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv); + bool MozIsLocallyAvailable(const nsAString& aURI, bool aWhenOffline, + ErrorResult& aRv) + { + bool available = false; + aRv = MozIsLocallyAvailable(aURI, aWhenOffline, &available); + return available; + } + nsIDOMMozSmsManager* GetMozSms(); + nsIDOMMozMobileMessageManager* GetMozMobileMessage(); + nsIDOMMozConnection* GetMozConnection(); + nsDOMCameraManager* GetMozCameras(ErrorResult& aRv); + void MozSetMessageHandler(const nsAString& aType, + systemMessageCallback* aCallback, + ErrorResult& aRv); + bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv); + // WebIDL helper methods static bool HasBatterySupport(JSContext* /* unused*/, JSObject* /*unused */); static bool HasPowerSupport(JSContext* /* unused */, JSObject* aGlobal); static bool HasIdleSupport(JSContext* /* unused */, JSObject* aGlobal); static bool HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */); + static bool HasDesktopNotificationSupport(JSContext* /* unused*/, + JSObject* /*unused */) + { + return HasDesktopNotificationSupport(); + } + static bool HasSmsSupport(JSContext* /* unused */, JSObject* aGlobal); + static bool HasMobileMessageSupport(JSContext* /* unused */, + JSObject* aGlobal); + static bool HasCameraSupport(JSContext* /* unused */, + JSObject* aGlobal); nsPIDOMWindow* GetParentObject() const { return GetWindow(); @@ -298,6 +331,7 @@ public: private: bool CheckPermission(const char* type); static bool CheckPermission(nsPIDOMWindow* aWindow, const char* aType); + static bool HasMobileMessageSupport(nsPIDOMWindow* aWindow); // GetWindowFromGlobal returns the inner window for this global, if // any, else null. static already_AddRefed GetWindowFromGlobal(JSObject* aGlobal); diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 4dd3004eb30f..d09c51080414 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1707,13 +1707,16 @@ addExternalIface('LockedFile') addExternalIface('MediaList') addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True) addExternalIface('MozBoxObject', nativeType='nsIBoxObject') +addExternalIface('MozConnection', headerFile='nsIDOMConnection.h') addExternalIface('MozControllers', nativeType='nsIControllers') addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True) +addExternalIface('MozMobileMessageManager', headerFile='nsIDOMMobileMessageManager.h') addExternalIface('MozObserver', nativeType='nsIObserver', notflattened=True) addExternalIface('MozPowerManager', headerFile='nsIDOMPowerManager.h') addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource', notflattened=True) addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True) +addExternalIface('MozSmsManager', headerFile='nsIDOMSmsManager.h') addExternalIface('MozTreeBoxObject', nativeType='nsITreeBoxObject', notflattened=True) addExternalIface('MozTreeColumn', nativeType='nsITreeColumn', diff --git a/dom/camera/DOMCameraManager.cpp b/dom/camera/DOMCameraManager.cpp index 15fbeb758452..1e9e6bb40661 100644 --- a/dom/camera/DOMCameraManager.cpp +++ b/dom/camera/DOMCameraManager.cpp @@ -71,21 +71,27 @@ nsDOMCameraManager::~nsDOMCameraManager() obs->RemoveObserver(this, "xpcom-shutdown"); } -// static creator -already_AddRefed -nsDOMCameraManager::CheckPermissionAndCreateInstance(nsPIDOMWindow* aWindow) +bool +nsDOMCameraManager::CheckPermission(nsPIDOMWindow* aWindow) { nsCOMPtr permMgr = do_GetService(NS_PERMISSIONMANAGER_CONTRACTID); - NS_ENSURE_TRUE(permMgr, nullptr); + NS_ENSURE_TRUE(permMgr, false); uint32_t permission = nsIPermissionManager::DENY_ACTION; permMgr->TestPermissionFromWindow(aWindow, "camera", &permission); if (permission != nsIPermissionManager::ALLOW_ACTION) { NS_WARNING("No permission to access camera"); - return nullptr; + return false; } + return true; +} + +// static creator +already_AddRefed +nsDOMCameraManager::CreateInstance(nsPIDOMWindow* aWindow) +{ // Initialize the shared active window tracker if (!sActiveWindowsInitialized) { sActiveWindows.Init(); diff --git a/dom/camera/DOMCameraManager.h b/dom/camera/DOMCameraManager.h index 26498fee918e..d22a679974d6 100644 --- a/dom/camera/DOMCameraManager.h +++ b/dom/camera/DOMCameraManager.h @@ -45,8 +45,9 @@ public: nsIObserver) NS_DECL_NSIOBSERVER + static bool CheckPermission(nsPIDOMWindow* aWindow); static already_AddRefed - CheckPermissionAndCreateInstance(nsPIDOMWindow* aWindow); + CreateInstance(nsPIDOMWindow* aWindow); static bool IsWindowStillActive(uint64_t aWindowId); void Register(mozilla::nsDOMCameraControl* aDOMCameraControl); diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 13e7090cc40b..5241495a63a7 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -1095,9 +1095,9 @@ MediaManager::GetUserMedia(bool aPrivileged, nsPIDOMWindow* aWindow, #ifdef MOZ_B2G_CAMERA if (mCameraManager == nullptr) { - mCameraManager = nsDOMCameraManager::CheckPermissionAndCreateInstance(aWindow); - if (!mCameraManager) { - aPrivileged = false; + aPrivileged = nsDOMCameraManager::CheckPermission(aWindow); + if (aPrivileged) { + mCameraManager = nsDOMCameraManager::CreateInstance(aWindow); } } #endif diff --git a/dom/mobilemessage/src/SmsManager.cpp b/dom/mobilemessage/src/SmsManager.cpp index 2adb96048b29..1d73cb700cd2 100644 --- a/dom/mobilemessage/src/SmsManager.cpp +++ b/dom/mobilemessage/src/SmsManager.cpp @@ -54,41 +54,49 @@ NS_IMPL_EVENT_HANDLER(SmsManager, failed) NS_IMPL_EVENT_HANDLER(SmsManager, deliverysuccess) NS_IMPL_EVENT_HANDLER(SmsManager, deliveryerror) -/* static */already_AddRefed -SmsManager::CreateInstanceIfAllowed(nsPIDOMWindow* aWindow) +/* static */ +bool +SmsManager::CreationIsAllowed(nsPIDOMWindow* aWindow) { NS_ASSERTION(aWindow, "Null pointer!"); #ifndef MOZ_WEBSMS_BACKEND - return nullptr; + return false; #endif // First of all, the general pref has to be turned on. bool enabled = false; Preferences::GetBool("dom.sms.enabled", &enabled); - NS_ENSURE_TRUE(enabled, nullptr); + NS_ENSURE_TRUE(enabled, false); nsCOMPtr permMgr = do_GetService(NS_PERMISSIONMANAGER_CONTRACTID); - NS_ENSURE_TRUE(permMgr, nullptr); + NS_ENSURE_TRUE(permMgr, false); uint32_t permission = nsIPermissionManager::DENY_ACTION; permMgr->TestPermissionFromWindow(aWindow, "sms", &permission); if (permission != nsIPermissionManager::ALLOW_ACTION) { - return nullptr; + return false; } // Check the Sms Service: nsCOMPtr smsService = do_GetService(SMS_SERVICE_CONTRACTID); - NS_ENSURE_TRUE(smsService, nullptr); + NS_ENSURE_TRUE(smsService, false); bool result = false; smsService->HasSupport(&result); if (!result) { - return nullptr; + return false; } + return true; +} + +// static +already_AddRefed +SmsManager::CreateInstance(nsPIDOMWindow* aWindow) +{ nsRefPtr smsMgr = new SmsManager(); smsMgr->Init(aWindow); diff --git a/dom/mobilemessage/src/SmsManager.h b/dom/mobilemessage/src/SmsManager.h index d69c0c14746e..622092527130 100644 --- a/dom/mobilemessage/src/SmsManager.h +++ b/dom/mobilemessage/src/SmsManager.h @@ -27,7 +27,10 @@ public: NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper) static already_AddRefed - CreateInstanceIfAllowed(nsPIDOMWindow *aWindow); + CreateInstance(nsPIDOMWindow *aWindow); + + static bool + CreationIsAllowed(nsPIDOMWindow *aWindow); void Init(nsPIDOMWindow *aWindow); void Shutdown(); diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index e0ae7f682f0e..73e66584c7ee 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -9,6 +9,7 @@ * http://www.w3.org/TR/geolocation-API/#geolocation_interface * http://www.w3.org/TR/battery-status/#navigatorbattery-interface * http://www.w3.org/TR/vibration/#vibration-interface + * http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1 * * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and * Opera Software ASA. You are granted a license to use, reproduce @@ -202,3 +203,59 @@ partial interface Navigator { [Throws, Func="Navigator::HasWakeLockSupport"] MozWakeLock requestWakeLock(DOMString aTopic); }; + +// nsIDOMNavigatorDeviceStorage +partial interface Navigator { + [Throws, Pref="device.storage.enabled"] + DeviceStorage? getDeviceStorage(DOMString type); + [Throws, Pref="device.storage.enabled"] + sequence getDeviceStorages(DOMString type); +}; + +// nsIDOMNavigatorDesktopNotification +partial interface Navigator { + [Throws, Func="Navigator::HasDesktopNotificationSupport"] + readonly attribute DesktopNotificationCenter mozNotification; +}; + +// nsIDOMClientInformation +partial interface Navigator { + [Throws] + boolean mozIsLocallyAvailable(DOMString uri, boolean whenOffline); +}; + +// nsIDOMMozNavigatorSms +interface MozSmsManager; +partial interface Navigator { + [Func="Navigator::HasSmsSupport"] + readonly attribute MozSmsManager? mozSms; +}; + +// nsIDOMMozNavigatorMobileMessage +interface MozMobileMessageManager; +partial interface Navigator { + [Func="Navigator::HasMobileMessageSupport"] + readonly attribute MozMobileMessageManager? mozMobileMessage; +}; + +// nsIDOMMozNavigatorNetwork +interface MozConnection; +partial interface Navigator { + readonly attribute MozConnection? mozConnection; +}; + +// nsIDOMNavigatorCamera +partial interface Navigator { + [Throws, Func="Navigator::HasCameraSupport"] + readonly attribute CameraManager mozCameras; +}; + +// nsIDOMNavigatorSystemMessages and sort of maybe +// http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1 +callback systemMessageCallback = void (optional object message); +partial interface Navigator { + [Throws, Pref="dom.sysmsg.enabled"] + void mozSetMessageHandler (DOMString type, systemMessageCallback? callback); + [Throws, Pref="dom.sysmsg.enabled"] + boolean mozHasPendingMessage (DOMString type); +};