Bug 858893 - Port DesktopNotification to WebIDL. r=Ms2ger
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 10 Apr 2013 10:20:43 -0400
changeset 135114 9f92f6c2d0deca31fb9c389356e1cb9b4b990972
parent 135113 64d2859ca6b19a8d0558bf09e14d4cc14ff46275
child 135115 850ae0bd07785877c06b1029e69b9675a4f69ac4
push id3752
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 17:21:10 +0000
treeherdermozilla-aurora@1580544aef0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
bugs858893
milestone23.0a1
Bug 858893 - Port DesktopNotification to WebIDL. r=Ms2ger
dom/base/Navigator.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/base/nsGlobalWindow.cpp
dom/bindings/Bindings.conf
dom/interfaces/notification/nsIDOMDesktopNotification.idl
dom/interfaces/notification/nsIDOMNavigatorDesktopNotification.idl
dom/src/notification/DesktopNotification.cpp
dom/src/notification/DesktopNotification.h
dom/webidl/DesktopNotification.webidl
dom/webidl/WebIDL.mk
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1156,17 +1156,17 @@ Navigator::MozGetUserMediaDevices(nsIGet
   return manager->GetUserMediaDevices(win, aOnSuccess, aOnError);
 }
 #endif
 
 //*****************************************************************************
 //    Navigator::nsIDOMNavigatorDesktopNotification
 //*****************************************************************************
 
-NS_IMETHODIMP Navigator::GetMozNotification(nsIDOMDesktopNotificationCenter** aRetVal)
+NS_IMETHODIMP Navigator::GetMozNotification(nsISupports** aRetVal)
 {
   NS_ENSURE_ARG_POINTER(aRetVal);
   *aRetVal = nullptr;
 
   if (mNotification) {
     NS_ADDREF(*aRetVal = mNotification);
     return NS_OK;
   }
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -279,17 +279,16 @@
 #endif
 
 // Workers
 #include "mozilla/dom/workers/Workers.h"
 
 #include "nsDOMFile.h"
 #include "nsDOMFileReader.h"
 
-#include "nsIDOMDesktopNotification.h"
 #include "nsIDOMNavigatorDesktopNotification.h"
 #include "nsIDOMNavigatorDeviceStorage.h"
 #include "nsIDOMNavigatorGeolocation.h"
 #include "Navigator.h"
 
 #include "nsPluginArray.h"
 #include "nsMimeTypeArray.h"
 
@@ -962,21 +961,16 @@ static nsDOMClassInfoData sClassInfoData
   NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentFrameMessageManager, nsEventTargetSH,
                                        DOM_DEFAULT_SCRIPTABLE_FLAGS |
                                        nsIXPCScriptable::IS_GLOBAL_OBJECT)
   NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageBroadcaster, nsDOMGenericSH,
                                        DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageSender, nsDOMGenericSH,
                                        DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
-  NS_DEFINE_CLASSINFO_DATA(DesktopNotification, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
-  NS_DEFINE_CLASSINFO_DATA(DesktopNotificationCenter, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
-
   NS_DEFINE_CLASSINFO_DATA_WITH_NAME(IDBFileHandle, FileHandle, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(IDBRequest, IDBEventTargetSH,
                            IDBEVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(IDBDatabase, IDBEventTargetSH,
                            IDBEVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(IDBObjectStore, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -2447,24 +2441,16 @@ nsDOMClassInfo::Init()
 
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeMessageSender, nsISupports)
     DOM_CLASSINFO_MAP_ENTRY(nsIProcessChecker)
     DOM_CLASSINFO_MAP_ENTRY(nsIFrameScriptLoader)
     DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
     DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(DesktopNotification, nsIDOMDesktopNotification)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMDesktopNotification)
-  DOM_CLASSINFO_MAP_END
-
-  DOM_CLASSINFO_MAP_BEGIN(DesktopNotificationCenter, nsIDOMDesktopNotificationCenter)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMDesktopNotificationCenter)
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN(IDBFileHandle, nsIDOMFileHandle)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileHandle)
     DOM_CLASSINFO_MAP_ENTRY(nsIIDBFileHandle)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(IDBRequest, nsIIDBRequest)
     DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -220,19 +220,16 @@ DOMCI_CLASS(EventListenerInfo)
 
 DOMCI_CLASS(TransitionEvent)
 DOMCI_CLASS(AnimationEvent)
 
 DOMCI_CLASS(ContentFrameMessageManager)
 DOMCI_CLASS(ChromeMessageBroadcaster)
 DOMCI_CLASS(ChromeMessageSender)
 
-DOMCI_CLASS(DesktopNotification)
-DOMCI_CLASS(DesktopNotificationCenter)
-
 DOMCI_CLASS(IDBFileHandle)
 DOMCI_CLASS(IDBRequest)
 DOMCI_CLASS(IDBDatabase)
 DOMCI_CLASS(IDBObjectStore)
 DOMCI_CLASS(IDBTransaction)
 DOMCI_CLASS(IDBCursor)
 DOMCI_CLASS(IDBCursorWithValue)
 DOMCI_CLASS(IDBKeyRange)
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -92,17 +92,16 @@
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsIDOMKeyEvent.h"
 #include "nsIDOMMessageEvent.h"
 #include "nsIDOMPopupBlockedEvent.h"
 #include "nsIDOMPopStateEvent.h"
 #include "nsIDOMHashChangeEvent.h"
 #include "nsIDOMOfflineResourceList.h"
 #include "nsIDOMGeoGeolocation.h"
-#include "nsIDOMDesktopNotification.h"
 #include "nsPIDOMStorage.h"
 #include "nsDOMString.h"
 #include "nsIEmbeddingSiteWindow.h"
 #include "nsThreadUtils.h"
 #include "nsEventStateManager.h"
 #include "nsIHttpProtocolHandler.h"
 #include "nsIJSContextStack.h"
 #include "nsIJSRuntimeService.h"
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -222,16 +222,20 @@ DOMInterfaces = {
 },
 
 'DelayNode': [
 {
     'resultNotAddRefed': [ 'delayTime' ],
     'wrapperCache': False
 }],
 
+'DesktopNotificationCenter': {
+    'headerFile': 'mozilla/dom/DesktopNotification.h',
+},
+
 'Document': [
 {
     'nativeType': 'nsIDocument',
     'hasXPConnectImpls': True,
     'resultNotAddRefed': [ 'implementation', 'doctype', 'documentElement',
                            'getElementById', 'adoptNode', 'defaultView',
                            'activeElement', 'currentScript',
                            'mozFullScreenElement', 'mozPointerLockElement',
--- a/dom/interfaces/notification/nsIDOMDesktopNotification.idl
+++ b/dom/interfaces/notification/nsIDOMDesktopNotification.idl
@@ -1,36 +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/. */
 
 #include "domstubs.idl"
 
-interface nsIDOMEventListener;
-interface nsIDOMDesktopNotification;
 interface nsIObserver;
 
-[scriptable, uuid(CCEA6185-0A3D-45AB-9058-1004DD4B8C50)]
-interface nsIDOMDesktopNotificationCenter : nsISupports
-{
-  nsIDOMDesktopNotification createNotification(in DOMString title,
-                                               in DOMString description,
-                                               [optional] in DOMString iconURL);
-};
-
-
-[scriptable, uuid(77bc6adc-77d6-4b29-9844-7eaac25e995d)]
-interface nsIDOMDesktopNotification : nsISupports
-{
-  void show();
-
-  [implicit_jscontext] attribute jsval onclick;
-  [implicit_jscontext] attribute jsval onclose;
-};
-
 // Notification service that also provides the manifest URL
 [scriptable, uuid(7fb4f0f9-ff5b-4620-8e1b-d82d723605af)]
 interface nsIAppNotificationService : nsISupports
 {
     void showAppNotification(in AString  imageUrl,
                               in AString  title,
                               in AString  text,
                               [optional] in boolean textClickable,
--- a/dom/interfaces/notification/nsIDOMNavigatorDesktopNotification.idl
+++ b/dom/interfaces/notification/nsIDOMNavigatorDesktopNotification.idl
@@ -1,15 +1,15 @@
 /* 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 "domstubs.idl"
-interface nsIDOMDesktopNotificationCenter;
 
 /**
  * Property that extends the navigator object.
  */
 [scriptable, uuid(EC2E6E4F-2F65-439C-B6C6-27E89B03B348)]
 interface nsIDOMNavigatorDesktopNotification : nsISupports
 {
-  readonly attribute nsIDOMDesktopNotificationCenter mozNotification;
+  /* DesktopNotificationCenter */
+  readonly attribute nsISupports mozNotification;
 };
--- a/dom/src/notification/DesktopNotification.cpp
+++ b/dom/src/notification/DesktopNotification.cpp
@@ -1,26 +1,23 @@
 /* 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 "mozilla/dom/DesktopNotification.h"
+#include "mozilla/dom/DesktopNotificationBinding.h"
 
 #include "nsContentPermissionHelper.h"
 #include "nsXULAppAPI.h"
 
 #include "mozilla/dom/PBrowserChild.h"
 #include "TabChild.h"
 #include "mozilla/Preferences.h"
 #include "nsGlobalWindow.h"
 #include "nsIAppsService.h"
-#include "nsIDOMDesktopNotification.h"
-
-DOMCI_DATA(DesktopNotification, mozilla::dom::DesktopNotification)
-DOMCI_DATA(DesktopNotificationCenter, mozilla::dom::DesktopNotificationCenter)
 
 namespace mozilla {
 namespace dom {
 
 /* ------------------------------------------------------------------------ */
 /* AlertServiceObserver                                                     */
 /* ------------------------------------------------------------------------ */
 
@@ -30,18 +27,19 @@ NS_IMPL_ISUPPORTS1(AlertServiceObserver,
 /* DesktopNotification                                                      */
 /* ------------------------------------------------------------------------ */
 
 uint32_t DesktopNotification::sCount = 0;
 
 nsresult
 DesktopNotification::PostDesktopNotification()
 {
-  if (!mObserver)
+  if (!mObserver) {
     mObserver = new AlertServiceObserver(this);
+  }
 
 #ifdef MOZ_B2G
   nsCOMPtr<nsIAppNotificationService> appNotifier =
     do_GetService("@mozilla.org/system-alerts-service;1");
   if (appNotifier) {
     nsCOMPtr<nsPIDOMWindow> window = GetOwner();
     uint32_t appId = (window.get())->GetDoc()->NodePrincipal()->GetAppId();
 
@@ -53,45 +51,35 @@ DesktopNotification::PostDesktopNotifica
                                               true,
                                               manifestUrl,
                                               mObserver);
     }
   }
 #endif
 
   nsCOMPtr<nsIAlertsService> alerts = do_GetService("@mozilla.org/alerts-service;1");
-  if (!alerts)
+  if (!alerts) {
     return NS_ERROR_NOT_IMPLEMENTED;
+  }
 
   // Generate a unique name (which will also be used as a cookie) because
   // the nsIAlertsService will coalesce notifications with the same name.
   // In the case of IPC, the parent process will use the cookie to map
   // to nsIObservers, thus cookies must be unique to differentiate observers.
   nsString uniqueName = NS_LITERAL_STRING("desktop-notification:");
   uniqueName.AppendInt(sCount++);
   return alerts->ShowAlertNotification(mIconURL, mTitle, mDescription,
                                        true,
                                        uniqueName,
                                        mObserver,
                                        uniqueName,
                                        NS_LITERAL_STRING("auto"),
                                        EmptyString());
 }
 
-NS_INTERFACE_MAP_BEGIN(DesktopNotification)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDesktopNotification)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DesktopNotification)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
-
-NS_IMPL_ADDREF_INHERITED(DesktopNotification, nsDOMEventTargetHelper)
-NS_IMPL_RELEASE_INHERITED(DesktopNotification, nsDOMEventTargetHelper)
-
-NS_IMPL_EVENT_HANDLER(DesktopNotification, click)
-NS_IMPL_EVENT_HANDLER(DesktopNotification, close)
-
 DesktopNotification::DesktopNotification(const nsAString & title,
                                          const nsAString & description,
                                          const nsAString & iconURL,
                                          nsPIDOMWindow *aWindow,
                                          nsIPrincipal* principal)
   : mTitle(title)
   , mDescription(description)
   , mIconURL(iconURL)
@@ -105,16 +93,18 @@ DesktopNotification::DesktopNotification
   }
 
   // If we are in testing mode (running mochitests, for example)
   // and we are suppose to allow requests, then just post an allow event.
   if (Preferences::GetBool("notification.prompt.testing", false) &&
       Preferences::GetBool("notification.prompt.testing.allow", true)) {
     mAllow = true;
   }
+
+  SetIsDOMBinding();
 }
 
 void
 DesktopNotification::Init()
 {
   nsRefPtr<DesktopNotificationRequest> request = new DesktopNotificationRequest(this);
 
   // if we are in the content process, then remote it to the parent.
@@ -174,104 +164,117 @@ DesktopNotification::DispatchNotificatio
 }
 
 nsresult
 DesktopNotification::SetAllow(bool aAllow)
 {
   mAllow = aAllow;
 
   // if we have called Show() already, lets go ahead and post a notification
-  if (mShowHasBeenCalled && aAllow)
+  if (mShowHasBeenCalled && aAllow) {
     return PostDesktopNotification();
+  }
 
   return NS_OK;
 }
 
 void
 DesktopNotification::HandleAlertServiceNotification(const char *aTopic)
 {
-  if (NS_FAILED(CheckInnerWindowCorrectness()))
+  if (NS_FAILED(CheckInnerWindowCorrectness())) {
     return;
+  }
 
   if (!strcmp("alertclickcallback", aTopic)) {
     DispatchNotificationEvent(NS_LITERAL_STRING("click"));
   } else if (!strcmp("alertfinished", aTopic)) {
     DispatchNotificationEvent(NS_LITERAL_STRING("close"));
   }
 }
 
-NS_IMETHODIMP
-DesktopNotification::Show()
+void
+DesktopNotification::Show(ErrorResult& aRv)
 {
   mShowHasBeenCalled = true;
 
-  if (!mAllow)
-    return NS_OK;
+  if (!mAllow) {
+    return;
+  }
 
-  return PostDesktopNotification();
+  aRv = PostDesktopNotification();
+}
+
+JSObject*
+DesktopNotification::WrapObject(JSContext* aCx, JSObject* aScope)
+{
+  return DesktopNotificationBinding::Wrap(aCx, aScope, this);
 }
 
 /* ------------------------------------------------------------------------ */
 /* DesktopNotificationCenter                                                */
 /* ------------------------------------------------------------------------ */
 
-NS_INTERFACE_MAP_BEGIN(DesktopNotificationCenter)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMDesktopNotificationCenter)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDesktopNotificationCenter)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DesktopNotificationCenter)
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(DesktopNotificationCenter)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(DesktopNotificationCenter)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(DesktopNotificationCenter)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DesktopNotificationCenter)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
-NS_IMPL_ADDREF(DesktopNotificationCenter)
-NS_IMPL_RELEASE(DesktopNotificationCenter)
-
-NS_IMETHODIMP
-DesktopNotificationCenter::CreateNotification(const nsAString & title,
-                                              const nsAString & description,
-                                              const nsAString & iconURL,
-                                              nsIDOMDesktopNotification **aResult)
+already_AddRefed<DesktopNotification>
+DesktopNotificationCenter::CreateNotification(const nsAString& aTitle,
+                                              const nsAString& aDescription,
+                                              const nsAString& aIconURL)
 {
-  NS_ENSURE_STATE(mOwner);
-  nsRefPtr<DesktopNotification> notification = new DesktopNotification(title,
-                                                                       description,
-                                                                       iconURL,
-                                                                       mOwner,
-                                                                       mPrincipal);
+  MOZ_ASSERT(mOwner);
+
+  nsRefPtr<DesktopNotification> notification =
+    new DesktopNotification(aTitle,
+                            aDescription,
+                            aIconURL,
+                            mOwner,
+                            mPrincipal);
   notification->Init();
-  notification.forget(aResult);
-  return NS_OK;
+  return notification.forget();
 }
 
+JSObject*
+DesktopNotificationCenter::WrapObject(JSContext* aCx, JSObject* aScope)
+{
+  return DesktopNotificationCenterBinding::Wrap(aCx, aScope, this);
+}
 
 /* ------------------------------------------------------------------------ */
 /* DesktopNotificationRequest                                               */
 /* ------------------------------------------------------------------------ */
 
 NS_IMPL_ISUPPORTS2(DesktopNotificationRequest,
                    nsIContentPermissionRequest,
                    nsIRunnable)
 
 NS_IMETHODIMP
 DesktopNotificationRequest::GetPrincipal(nsIPrincipal * *aRequestingPrincipal)
 {
-  if (!mDesktopNotification)
+  if (!mDesktopNotification) {
     return NS_ERROR_NOT_INITIALIZED;
+  }
 
   NS_IF_ADDREF(*aRequestingPrincipal = mDesktopNotification->mPrincipal);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DesktopNotificationRequest::GetWindow(nsIDOMWindow * *aRequestingWindow)
 {
-  if (!mDesktopNotification)
+  if (!mDesktopNotification) {
     return NS_ERROR_NOT_INITIALIZED;
+  }
 
-  nsCOMPtr<nsIDOMWindow> window =
-    do_QueryInterface(mDesktopNotification->GetOwner());
-  NS_IF_ADDREF(*aRequestingWindow = window);
+  NS_IF_ADDREF(*aRequestingWindow = mDesktopNotification->GetOwner());
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DesktopNotificationRequest::GetElement(nsIDOMElement * *aElement)
 {
   return NS_ERROR_FAILURE;
 }
--- a/dom/src/notification/DesktopNotification.h
+++ b/dom/src/notification/DesktopNotification.h
@@ -2,89 +2,102 @@
  * 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_DesktopNotification_h
 #define mozilla_dom_DesktopNotification_h
 
 #include "PCOMContentPermissionRequestChild.h"
 
-#include "nsDOMClassInfoID.h"
 #include "nsIPrincipal.h"
 #include "nsIJSContextStack.h"
 
 #include "nsIAlertsService.h"
 
-#include "nsIDOMDesktopNotification.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIContentPermissionPrompt.h"
 
 #include "nsIObserver.h"
 #include "nsString.h"
 #include "nsWeakPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIDOMWindow.h"
 #include "nsThreadUtils.h"
 
 #include "nsDOMEventTargetHelper.h"
 #include "nsIDOMEvent.h"
 #include "nsIDocument.h"
 
+#include "mozilla/Attributes.h"
+#include "mozilla/ErrorResult.h"
+#include "nsWrapperCache.h"
+
+
 namespace mozilla {
 namespace dom {
 
 class AlertServiceObserver;
+class DesktopNotification;
 
 /*
  * DesktopNotificationCenter
  * Object hangs off of the navigator object and hands out DesktopNotification objects
  */
-class DesktopNotificationCenter : public nsIDOMDesktopNotificationCenter
+class DesktopNotificationCenter MOZ_FINAL : public nsISupports,
+                                            public nsWrapperCache
 {
 public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIDOMDESKTOPNOTIFICATIONCENTER
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DesktopNotificationCenter)
 
   DesktopNotificationCenter(nsPIDOMWindow *aWindow)
   {
     mOwner = aWindow;
 
     // Grab the uri of the document
-    nsCOMPtr<nsIDOMDocument> domdoc;
-    mOwner->GetDocument(getter_AddRefs(domdoc));
-    nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
-    mPrincipal = doc->NodePrincipal();
+    mPrincipal = mOwner->GetDoc()->NodePrincipal();
+
+    SetIsDOMBinding();
   }
 
   virtual ~DesktopNotificationCenter()
   {
   }
 
   void Shutdown() {
     mOwner = nullptr;
   }
 
+  nsPIDOMWindow* GetParentObject() const
+  {
+    return mOwner;
+  }
+
+  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+
+  already_AddRefed<DesktopNotification>
+  CreateNotification(const nsAString& title,
+                     const nsAString& description,
+                     const nsAString& iconURL);
+
 private:
   nsCOMPtr<nsPIDOMWindow> mOwner;
   nsCOMPtr<nsIPrincipal> mPrincipal;
 };
 
 
-class DesktopNotification : public nsDOMEventTargetHelper,
-                            public nsIDOMDesktopNotification
+class DesktopNotification MOZ_FINAL : public nsDOMEventTargetHelper
 {
   friend class DesktopNotificationRequest;
 
 public:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMDESKTOPNOTIFICATION
 
-  DesktopNotification(const nsAString & title,
-                      const nsAString & description,
-                      const nsAString & iconURL,
+  DesktopNotification(const nsAString& aTitle,
+                      const nsAString& aDescription,
+                      const nsAString& aIconURL,
                       nsPIDOMWindow *aWindow,
                       nsIPrincipal* principal);
 
   virtual ~DesktopNotification();
 
   void Init();
 
   /*
@@ -97,16 +110,30 @@ public:
 
   /*
    * Creates and dispatches a dom event of type aName
    */
   void DispatchNotificationEvent(const nsString& aName);
 
   void HandleAlertServiceNotification(const char *aTopic);
 
+  // WebIDL
+
+  nsPIDOMWindow* GetParentObject() const
+  {
+    return GetOwner();
+  }
+
+  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+
+  void Show(ErrorResult& aRv);
+
+  IMPL_EVENT_HANDLER(click)
+  IMPL_EVENT_HANDLER(close)
+
 protected:
 
   nsString mTitle;
   nsString mDescription;
   nsString mIconURL;
 
   nsRefPtr<AlertServiceObserver> mObserver;
   nsCOMPtr<nsIPrincipal> mPrincipal;
new file mode 100644
--- /dev/null
+++ b/dom/webidl/DesktopNotification.webidl
@@ -0,0 +1,27 @@
+/* -*- Mode: IDL; 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/.
+ */
+
+interface MozObserver;
+
+interface DesktopNotificationCenter
+{
+  [Creator]
+  DesktopNotification createNotification(DOMString title,
+                                         DOMString description,
+                                         optional DOMString iconURL = "");
+};
+
+interface DesktopNotification : EventTarget
+{
+  [Throws]
+  void show();
+
+  [SetterThrows]
+  attribute EventHandler onclick;
+
+  [SetterThrows]
+  attribute EventHandler onclose;
+};
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -38,16 +38,17 @@ webidl_files = \
   CompositionEvent.webidl \
   CSS.webidl \
   CSSPrimitiveValue.webidl \
   CSSStyleDeclaration.webidl \
   CSSStyleSheet.webidl \
   CSSValue.webidl \
   CSSValueList.webidl \
   DelayNode.webidl \
+  DesktopNotification.webidl \
   Document.webidl \
   DocumentFragment.webidl \
   DocumentType.webidl \
   DOMCursor.webidl \
   DOMImplementation.webidl \
   DOMParser.webidl \
   DOMRequest.webidl \
   DOMSettableTokenList.webidl \