diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index be7fb19d6fc..a9185c89461 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -160,6 +160,7 @@ @BINPATH@/components/dom_wifi.xpt @BINPATH@/components/dom_system_gonk.xpt @BINPATH@/components/dom_icc.xpt +@BINPATH@/components/dom_cellbroadcast.xpt #endif #ifdef MOZ_B2G_FM @BINPATH@/components/dom_fm.xpt diff --git a/dom/Makefile.in b/dom/Makefile.in index 3e18b772219..672e0653b7c 100644 --- a/dom/Makefile.in +++ b/dom/Makefile.in @@ -82,6 +82,7 @@ PARALLEL_DIRS += \ telephony \ wifi \ icc \ + cellbroadcast \ $(NULL) endif diff --git a/dom/apps/src/PermissionsInstaller.jsm b/dom/apps/src/PermissionsInstaller.jsm index e6dc3433b92..603e069946c 100644 --- a/dom/apps/src/PermissionsInstaller.jsm +++ b/dom/apps/src/PermissionsInstaller.jsm @@ -233,6 +233,11 @@ this.PermissionsTable = { geolocation: { privileged: DENY_ACTION, certified: ALLOW_ACTION }, + cellbroadcast: { + app: DENY_ACTION, + privileged: DENY_ACTION, + certified: ALLOW_ACTION + }, }; /** diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 0898f600144..1ef320e80e5 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -39,6 +39,7 @@ #include "Connection.h" #ifdef MOZ_B2G_RIL #include "MobileConnection.h" +#include "mozilla/dom/CellBroadcast.h" #endif #include "nsIIdleObserver.h" #include "nsIPermissionManager.h" @@ -127,6 +128,7 @@ NS_INTERFACE_MAP_BEGIN(Navigator) NS_INTERFACE_MAP_ENTRY(nsIDOMMozNavigatorNetwork) #ifdef MOZ_B2G_RIL NS_INTERFACE_MAP_ENTRY(nsIMozNavigatorMobileConnection) + NS_INTERFACE_MAP_ENTRY(nsIMozNavigatorCellBroadcast) #endif #ifdef MOZ_B2G_BT NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorBluetooth) @@ -201,6 +203,10 @@ Navigator::Invalidate() mMobileConnection->Shutdown(); mMobileConnection = nullptr; } + + if (mCellBroadcast) { + mCellBroadcast = nullptr; + } #endif #ifdef MOZ_B2G_BT @@ -1166,6 +1172,31 @@ Navigator::GetMozSms(nsIDOMMozSmsManager** aSmsManager) #ifdef MOZ_B2G_RIL +//***************************************************************************** +// Navigator::nsIMozNavigatorCellBroadcast +//***************************************************************************** + +NS_IMETHODIMP +Navigator::GetMozCellBroadcast(nsIDOMMozCellBroadcast** aCellBroadcast) +{ + *aCellBroadcast = nullptr; + + if (!mCellBroadcast) { + nsCOMPtr window = do_QueryReferent(mWindow); + NS_ENSURE_TRUE(window, NS_OK); + + if (!CheckPermission("cellbroadcast")) { + return NS_OK; + } + + nsresult rv = NS_NewCellBroadcast(window, getter_AddRefs(mCellBroadcast)); + NS_ENSURE_SUCCESS(rv, rv); + } + + NS_ADDREF(*aCellBroadcast = mCellBroadcast); + return NS_OK; +} + //***************************************************************************** // nsNavigator::nsIDOMNavigatorTelephony //***************************************************************************** diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 382f5faf136..87059ff2397 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -20,6 +20,7 @@ #endif #ifdef MOZ_B2G_RIL #include "nsINavigatorMobileConnection.h" +#include "nsINavigatorCellBroadcast.h" #endif #include "nsAutoPtr.h" #include "nsIDOMNavigatorTime.h" @@ -105,6 +106,7 @@ class Navigator : public nsIDOMNavigator , public nsIDOMMozNavigatorNetwork #ifdef MOZ_B2G_RIL , public nsIMozNavigatorMobileConnection + , public nsIMozNavigatorCellBroadcast #endif #ifdef MOZ_B2G_BT , public nsIDOMNavigatorBluetooth @@ -140,6 +142,7 @@ public: NS_DECL_NSIDOMMOZNAVIGATORNETWORK #ifdef MOZ_B2G_RIL NS_DECL_NSIMOZNAVIGATORMOBILECONNECTION + NS_DECL_NSIMOZNAVIGATORCELLBROADCAST #endif #ifdef MOZ_B2G_BT @@ -197,6 +200,7 @@ private: nsRefPtr mConnection; #ifdef MOZ_B2G_RIL nsRefPtr mMobileConnection; + nsCOMPtr mCellBroadcast; #endif #ifdef MOZ_B2G_BT nsCOMPtr mBluetooth; diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index ccfd6e10ed0..9b8e000cc05 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -504,6 +504,7 @@ using mozilla::dom::indexedDB::IDBWrapperCache; #include "nsIDOMVoicemailEvent.h" #include "nsIDOMIccManager.h" #include "StkCommandEvent.h" +#include "nsIDOMMozCellBroadcast.h" #endif #ifdef MOZ_B2G_FM @@ -1505,6 +1506,9 @@ static nsDOMClassInfoData sClassInfoData[] = { #ifdef MOZ_B2G_RIL NS_DEFINE_CLASSINFO_DATA(MozMobileConnection, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) + + NS_DEFINE_CLASSINFO_DATA(MozCellBroadcast, nsDOMGenericSH, + DOM_DEFAULT_SCRIPTABLE_FLAGS) #endif NS_DEFINE_CLASSINFO_DATA(USSDReceivedEvent, nsDOMGenericSH, @@ -2469,6 +2473,7 @@ nsDOMClassInfo::Init() network::IsAPIEnabled()) #ifdef MOZ_B2G_RIL DOM_CLASSINFO_MAP_ENTRY(nsIMozNavigatorMobileConnection) + DOM_CLASSINFO_MAP_ENTRY(nsIMozNavigatorCellBroadcast) #endif #ifdef MOZ_B2G_BT DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorBluetooth) @@ -4099,6 +4104,11 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileConnection) DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) DOM_CLASSINFO_MAP_END + + DOM_CLASSINFO_MAP_BEGIN(MozCellBroadcast, nsIDOMMozCellBroadcast) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCellBroadcast) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) + DOM_CLASSINFO_MAP_END #endif DOM_CLASSINFO_MAP_BEGIN(USSDReceivedEvent, nsIDOMUSSDReceivedEvent) diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index c607332f328..64e278ed28a 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -402,6 +402,7 @@ DOMCI_CLASS(MozSmsCursor) DOMCI_CLASS(MozConnection) #ifdef MOZ_B2G_RIL DOMCI_CLASS(MozMobileConnection) +DOMCI_CLASS(MozCellBroadcast) #endif DOMCI_CLASS(USSDReceivedEvent) diff --git a/dom/cellbroadcast/Makefile.in b/dom/cellbroadcast/Makefile.in new file mode 100644 index 00000000000..d2bac5dd735 --- /dev/null +++ b/dom/cellbroadcast/Makefile.in @@ -0,0 +1,16 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DEPTH = @DEPTH@ +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +relativesrcdir = @relativesrcdir@ + +include $(DEPTH)/config/autoconf.mk + +PARALLEL_DIRS = interfaces src + +include $(topsrcdir)/config/rules.mk diff --git a/dom/cellbroadcast/interfaces/Makefile.in b/dom/cellbroadcast/interfaces/Makefile.in new file mode 100644 index 00000000000..eeb82577a0b --- /dev/null +++ b/dom/cellbroadcast/interfaces/Makefile.in @@ -0,0 +1,29 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DEPTH = @DEPTH@ +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +XPIDL_MODULE = dom_cellbroadcast + +include $(topsrcdir)/dom/dom-config.mk + +XPIDLSRCS = \ + nsIDOMMozCellBroadcast.idl \ + nsIDOMMozCellBroadcastEvent.idl \ + nsIDOMMozCellBroadcastMessage.idl \ + nsINavigatorCellBroadcast.idl \ + $(NULL) + +include $(topsrcdir)/config/rules.mk + +XPIDL_FLAGS += \ + -I$(topsrcdir)/dom/base \ + -I$(topsrcdir)/dom/interfaces/base \ + -I$(topsrcdir)/dom/interfaces/events \ + $(NULL) diff --git a/dom/cellbroadcast/src/CellBroadcast.cpp b/dom/cellbroadcast/src/CellBroadcast.cpp new file mode 100644 index 00000000000..5fa19913d91 --- /dev/null +++ b/dom/cellbroadcast/src/CellBroadcast.cpp @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "CellBroadcast.h" +#include "nsDOMClassInfo.h" + +DOMCI_DATA(MozCellBroadcast, mozilla::dom::CellBroadcast) + +namespace mozilla { +namespace dom { + +NS_IMPL_CYCLE_COLLECTION_CLASS(CellBroadcast) + +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(CellBroadcast, + nsDOMEventTargetHelper) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END + +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(CellBroadcast, + nsDOMEventTargetHelper) +NS_IMPL_CYCLE_COLLECTION_UNLINK_END + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CellBroadcast) + NS_INTERFACE_MAP_ENTRY(nsIDOMMozCellBroadcast) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMozCellBroadcast) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozCellBroadcast) +NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) + +NS_IMPL_ADDREF_INHERITED(CellBroadcast, nsDOMEventTargetHelper) +NS_IMPL_RELEASE_INHERITED(CellBroadcast, nsDOMEventTargetHelper) + +CellBroadcast::CellBroadcast(nsPIDOMWindow *aWindow) +{ + BindToOwner(aWindow); +} + +NS_IMPL_EVENT_HANDLER(CellBroadcast, received) + +} // namespace dom +} // namespace mozilla + +nsresult +NS_NewCellBroadcast(nsPIDOMWindow* aWindow, + nsIDOMMozCellBroadcast** aCellBroadcast) +{ + nsPIDOMWindow* innerWindow = aWindow->IsInnerWindow() ? + aWindow : + aWindow->GetCurrentInnerWindow(); + + nsRefPtr cb = + new mozilla::dom::CellBroadcast(innerWindow); + cb.forget(aCellBroadcast); + + return NS_OK; +} diff --git a/dom/cellbroadcast/src/CellBroadcast.h b/dom/cellbroadcast/src/CellBroadcast.h new file mode 100644 index 00000000000..1df22cf1d6a --- /dev/null +++ b/dom/cellbroadcast/src/CellBroadcast.h @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_CellBroadcast_h__ +#define mozilla_dom_CellBroadcast_h__ + +#include "nsDOMEventTargetHelper.h" +#include "nsIDOMMozCellBroadcast.h" +#include "mozilla/Attributes.h" + +class nsPIDOMWindow; + +namespace mozilla { +namespace dom { + +class CellBroadcast MOZ_FINAL : public nsDOMEventTargetHelper + , public nsIDOMMozCellBroadcast +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIDOMMOZCELLBROADCAST + + NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::) + + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CellBroadcast, + nsDOMEventTargetHelper) + + CellBroadcast() MOZ_DELETE; + CellBroadcast(nsPIDOMWindow *aWindow); +}; + +} // namespace dom +} // namespace mozilla + +nsresult +NS_NewCellBroadcast(nsPIDOMWindow* aWindow, + nsIDOMMozCellBroadcast** aCellBroadcast); + +#endif // mozilla_dom_CellBroadcast_h__ diff --git a/dom/cellbroadcast/src/Makefile.in b/dom/cellbroadcast/src/Makefile.in new file mode 100644 index 00000000000..b1fce366ab0 --- /dev/null +++ b/dom/cellbroadcast/src/Makefile.in @@ -0,0 +1,30 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DEPTH = @DEPTH@ +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +LIBRARY_NAME = dom_cellbroadcast_s +XPIDL_MODULE = dom_cellbroadcast +LIBXUL_LIBRARY = 1 +FORCE_STATIC_LIB = 1 +FAIL_ON_WARNINGS := 1 + +include $(topsrcdir)/dom/dom-config.mk + +EXPORTS_NAMESPACES = mozilla/dom + +EXPORTS_mozilla/dom = \ + CellBroadcast.h \ + $(NULL) + +CPPSRCS = \ + CellBroadcast.cpp \ + $(NULL) + +include $(topsrcdir)/config/rules.mk diff --git a/layout/build/Makefile.in b/layout/build/Makefile.in index dc7565d0a22..526f91da0cc 100644 --- a/layout/build/Makefile.in +++ b/layout/build/Makefile.in @@ -145,6 +145,7 @@ SHARED_LIBRARY_LIBS += \ $(DEPTH)/dom/system/gonk/$(LIB_PREFIX)domsystemgonk_s.$(LIB_SUFFIX) \ $(DEPTH)/dom/telephony/$(LIB_PREFIX)domtelephony_s.$(LIB_SUFFIX) \ $(DEPTH)/dom/icc/src/$(LIB_PREFIX)dom_icc_s.$(LIB_SUFFIX) \ + $(DEPTH)/dom/cellbroadcast/src/$(LIB_PREFIX)dom_cellbroadcast_s.$(LIB_SUFFIX) \ $(NULL) endif #}