Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 8d99337

Browse files
author
Doug Turner
committed
Bug 573588 - Implement Desktop Notifications r=smaug, a=beltzner
--HG-- extra : rebase_source : 05ec761dd838e4f85a63df677c6335e456a8dfd6
1 parent 30a0d1f commit 8d99337

16 files changed

Lines changed: 855 additions & 2 deletions

browser/installer/package-manifest.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
@BINPATH@/components/dom_css.xpt
150150
@BINPATH@/components/dom_events.xpt
151151
@BINPATH@/components/dom_geolocation.xpt
152+
@BINPATH@/components/dom_notification.xpt
152153
@BINPATH@/components/dom_html.xpt
153154
@BINPATH@/components/dom_indexeddb.xpt
154155
@BINPATH@/components/dom_offline.xpt

dom/Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ DIRS = \
6464
interfaces/offline \
6565
interfaces/geolocation \
6666
interfaces/threads \
67+
interfaces/notification \
6768
$(NULL)
6869

6970
ifdef MOZ_SVG

dom/base/nsDOMClassInfo.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@
466466
#include "nsIDOMFileError.h"
467467
#include "nsIDOMFormData.h"
468468

469+
#include "nsIDOMDesktopNotification.h"
470+
#include "nsIDOMNavigatorDesktopNotification.h"
471+
469472
// Simple gestures include
470473
#include "nsIDOMSimpleGestureEvent.h"
471474

@@ -1442,6 +1445,11 @@ static nsDOMClassInfoData sClassInfoData[] = {
14421445
NS_DEFINE_CLASSINFO_DATA(FormData, nsDOMGenericSH,
14431446
DOM_DEFAULT_SCRIPTABLE_FLAGS)
14441447

1448+
NS_DEFINE_CLASSINFO_DATA(DesktopNotification, nsDOMGenericSH,
1449+
DOM_DEFAULT_SCRIPTABLE_FLAGS)
1450+
NS_DEFINE_CLASSINFO_DATA(DesktopNotificationCenter, nsDOMGenericSH,
1451+
DOM_DEFAULT_SCRIPTABLE_FLAGS)
1452+
14451453
NS_DEFINE_CLASSINFO_DATA(WebSocket, nsEventTargetSH,
14461454
EVENTTARGET_SCRIPTABLE_FLAGS)
14471455

@@ -2262,6 +2270,7 @@ nsDOMClassInfo::Init()
22622270
DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator)
22632271
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigator)
22642272
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorGeolocation)
2273+
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorDesktopNotification)
22652274
DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation)
22662275
DOM_CLASSINFO_MAP_END
22672276

@@ -4043,6 +4052,14 @@ nsDOMClassInfo::Init()
40434052
DOM_CLASSINFO_MAP_ENTRY(nsIDOMFormData)
40444053
DOM_CLASSINFO_MAP_END
40454054

4055+
DOM_CLASSINFO_MAP_BEGIN(DesktopNotification, nsIDOMDesktopNotification)
4056+
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDesktopNotification)
4057+
DOM_CLASSINFO_MAP_END
4058+
4059+
DOM_CLASSINFO_MAP_BEGIN(DesktopNotificationCenter, nsIDOMDesktopNotificationCenter)
4060+
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDesktopNotificationCenter)
4061+
DOM_CLASSINFO_MAP_END
4062+
40464063
DOM_CLASSINFO_MAP_BEGIN(WebSocket, nsIWebSocket)
40474064
DOM_CLASSINFO_MAP_ENTRY(nsIWebSocket)
40484065
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)

dom/base/nsDOMClassInfoClasses.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,9 @@ DOMCI_CLASS(ContentFrameMessageManager)
485485

486486
DOMCI_CLASS(FormData)
487487

488+
DOMCI_CLASS(DesktopNotification)
489+
DOMCI_CLASS(DesktopNotificationCenter)
490+
488491
// WebSocket
489492
DOMCI_CLASS(WebSocket)
490493
DOMCI_CLASS(CloseEvent)

dom/base/nsGlobalWindow.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
#include "nsPluginArray.h"
7979
#include "nsIPluginHost.h"
8080
#include "nsGeolocation.h"
81+
#include "nsDesktopNotification.h"
8182
#include "nsContentCID.h"
8283
#include "nsLayoutStatics.h"
8384
#include "nsCycleCollector.h"
@@ -118,6 +119,7 @@
118119
#include "nsIDOMPopStateEvent.h"
119120
#include "nsIDOMOfflineResourceList.h"
120121
#include "nsIDOMGeoGeolocation.h"
122+
#include "nsIDOMDesktopNotification.h"
121123
#include "nsPIDOMStorage.h"
122124
#include "nsDOMString.h"
123125
#include "nsIEmbeddingSiteWindow2.h"
@@ -9849,6 +9851,7 @@ NS_INTERFACE_MAP_BEGIN(nsNavigator)
98499851
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigator)
98509852
NS_INTERFACE_MAP_ENTRY(nsIDOMClientInformation)
98519853
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorGeolocation)
9854+
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorDesktopNotification)
98529855
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Navigator)
98539856
NS_INTERFACE_MAP_END
98549857

@@ -10425,3 +10428,37 @@ NS_IMETHODIMP nsNavigator::GetGeolocation(nsIDOMGeoGeolocation **_retval)
1042510428
NS_ADDREF(*_retval = mGeolocation);
1042610429
return NS_OK;
1042710430
}
10431+
10432+
10433+
//*****************************************************************************
10434+
// nsNavigator::nsIDOMNavigatorDesktopNotification
10435+
//*****************************************************************************
10436+
10437+
NS_IMETHODIMP nsNavigator::GetMozNotification(nsIDOMDesktopNotificationCenter **aRetVal)
10438+
{
10439+
NS_ENSURE_ARG_POINTER(aRetVal);
10440+
*aRetVal = nsnull;
10441+
10442+
nsCOMPtr<nsPIDOMWindow> window(do_GetInterface(mDocShell));
10443+
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
10444+
10445+
nsCOMPtr<nsIDocument> document = do_GetInterface(mDocShell);
10446+
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
10447+
10448+
nsIScriptGlobalObject *sgo = document->GetScopeObject();
10449+
NS_ENSURE_TRUE(sgo, NS_ERROR_FAILURE);
10450+
10451+
nsIScriptContext *scx = sgo->GetContext();
10452+
NS_ENSURE_TRUE(scx, NS_ERROR_FAILURE);
10453+
10454+
nsRefPtr<nsDesktopNotificationCenter> notification =
10455+
new nsDesktopNotificationCenter(window->GetCurrentInnerWindow(),
10456+
scx);
10457+
10458+
if (!notification) {
10459+
return NS_ERROR_FAILURE;
10460+
}
10461+
10462+
*aRetVal = notification.forget().get();
10463+
return NS_OK;
10464+
}

dom/base/nsGlobalWindow.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#include "nsIDOMNSEventTarget.h"
6767
#include "nsIDOMNavigator.h"
6868
#include "nsIDOMNavigatorGeolocation.h"
69+
#include "nsIDOMNavigatorDesktopNotification.h"
6970
#include "nsIDOMLocation.h"
7071
#include "nsIDOMWindowInternal.h"
7172
#include "nsIInterfaceRequestor.h"
@@ -929,7 +930,8 @@ class nsGlobalModalWindow : public nsGlobalWindow,
929930

930931
class nsNavigator : public nsIDOMNavigator,
931932
public nsIDOMClientInformation,
932-
public nsIDOMNavigatorGeolocation
933+
public nsIDOMNavigatorGeolocation,
934+
public nsIDOMNavigatorDesktopNotification
933935
{
934936
public:
935937
nsNavigator(nsIDocShell *aDocShell);
@@ -939,6 +941,7 @@ class nsNavigator : public nsIDOMNavigator,
939941
NS_DECL_NSIDOMNAVIGATOR
940942
NS_DECL_NSIDOMCLIENTINFORMATION
941943
NS_DECL_NSIDOMNAVIGATORGEOLOCATION
944+
NS_DECL_NSIDOMNAVIGATORDESKTOPNOTIFICATION
942945

943946
void SetDocShell(nsIDocShell *aDocShell);
944947
nsIDocShell *GetDocShell()

dom/dom-config.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ DOM_SRCDIRS = \
66
dom/src/storage \
77
dom/src/offline \
88
dom/src/geolocation \
9+
dom/src/notification \
910
dom/src/threads \
1011
content/xbl/src \
1112
content/xul/document/src \
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# ***** BEGIN LICENSE BLOCK *****
2+
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
3+
#
4+
# The contents of this file are subject to the Mozilla Public License Version
5+
# 1.1 (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
# http://www.mozilla.org/MPL/
8+
#
9+
# Software distributed under the License is distributed on an "AS IS" basis,
10+
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11+
# for the specific language governing rights and limitations under the
12+
# License.
13+
#
14+
# The Original Code is mozilla.org build system.
15+
#
16+
# The Initial Developer of the Original Code is Mozilla Foundation
17+
# Portions created by the Initial Developer are Copyright (C) 2010
18+
# the Initial Developer. All Rights Reserved.
19+
#
20+
# Contributor(s):
21+
# Doug Turner <dougt@dougt.org>
22+
#
23+
# Alternatively, the contents of this file may be used under the terms of
24+
# either the GNU General Public License Version 2 or later (the "GPL"), or
25+
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26+
# in which case the provisions of the GPL or the LGPL are applicable instead
27+
# of those above. If you wish to allow use of your version of this file only
28+
# under the terms of either the GPL or the LGPL, and not to allow others to
29+
# use your version of this file under the terms of the MPL, indicate your
30+
# decision by deleting the provisions above and replace them with the notice
31+
# and other provisions required by the GPL or the LGPL. If you do not delete
32+
# the provisions above, a recipient may use your version of this file under
33+
# the terms of any one of the MPL, the GPL or the LGPL.
34+
#
35+
# ***** END LICENSE BLOCK *****
36+
37+
38+
DEPTH = ../../..
39+
topsrcdir = @top_srcdir@
40+
srcdir = @srcdir@
41+
VPATH = @srcdir@
42+
43+
include $(DEPTH)/config/autoconf.mk
44+
45+
MODULE = dom
46+
XPIDL_MODULE = dom_notification
47+
GRE_MODULE = 1
48+
49+
XPIDLSRCS = nsIDOMNavigatorDesktopNotification.idl \
50+
nsIDOMDesktopNotification.idl \
51+
nsIDesktopNotificationPrompt.idl \
52+
$(NULL)
53+
54+
include $(topsrcdir)/config/rules.mk
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* ***** BEGIN LICENSE BLOCK *****
2+
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
3+
*
4+
* The contents of this file are subject to the Mozilla Public License Version
5+
* 1.1 (the "License"); you may not use this file except in compliance with
6+
* the License. You may obtain a copy of the License at
7+
* http://www.mozilla.org/MPL/
8+
*
9+
* Software distributed under the License is distributed on an "AS IS" basis,
10+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11+
* for the specific language governing rights and limitations under the
12+
* License.
13+
*
14+
* The Original Code is DesktopNotification.
15+
*
16+
* The Initial Developer of the Original Code is Mozilla Foundation
17+
* Portions created by the Initial Developer are Copyright (C) 2010
18+
* the Initial Developer. All Rights Reserved.
19+
*
20+
* Contributor(s):
21+
* Doug Turner <dougt@dougt.org> (Original Author)
22+
*
23+
* Alternatively, the contents of this file may be used under the terms of
24+
* either the GNU General Public License Version 2 or later (the "GPL"), or
25+
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26+
* in which case the provisions of the GPL or the LGPL are applicable instead
27+
* of those above. If you wish to allow use of your version of this file only
28+
* under the terms of either the GPL or the LGPL, and not to allow others to
29+
* use your version of this file under the terms of the MPL, indicate your
30+
* decision by deleting the provisions above and replace them with the notice
31+
* and other provisions required by the GPL or the LGPL. If you do not delete
32+
* the provisions above, a recipient may use your version of this file under
33+
* the terms of any one of the MPL, the GPL or the LGPL.
34+
*
35+
* ***** END LICENSE BLOCK ***** */
36+
37+
#include "domstubs.idl"
38+
39+
interface nsIDOMEventListener;
40+
interface nsIDOMDesktopNotification;
41+
42+
43+
[scriptable, function, uuid(CCEA6185-0A3D-45AB-9058-1004DD4B8C50)]
44+
interface nsIDOMDesktopNotificationCenter : nsISupports
45+
{
46+
nsIDOMDesktopNotification createNotification(in DOMString title,
47+
in DOMString description,
48+
[optional] in DOMString iconURL);
49+
};
50+
51+
52+
[scriptable, function, uuid(9131FD07-A7DB-4B3A-A98B-6D9F3746682F)]
53+
interface nsIDOMDesktopNotification : nsISupports
54+
{
55+
void show();
56+
57+
attribute nsIDOMEventListener onclick;
58+
attribute nsIDOMEventListener onclose;
59+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* ***** BEGIN LICENSE BLOCK *****
2+
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
3+
*
4+
* The contents of this file are subject to the Mozilla Public License Version
5+
* 1.1 (the "License"); you may not use this file except in compliance with
6+
* the License. You may obtain a copy of the License at
7+
* http://www.mozilla.org/MPL/
8+
*
9+
* Software distributed under the License is distributed on an "AS IS" basis,
10+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11+
* for the specific language governing rights and limitations under the
12+
* License.
13+
*
14+
* The Original Code is DesktopNotification.
15+
*
16+
* The Initial Developer of the Original Code is Mozilla Foundation
17+
* Portions created by the Initial Developer are Copyright (C) 2010
18+
* the Initial Developer. All Rights Reserved.
19+
*
20+
* Contributor(s):
21+
* Doug Turner <dougt@dougt.org> (Original Author)
22+
*
23+
* Alternatively, the contents of this file may be used under the terms of
24+
* either the GNU General Public License Version 2 or later (the "GPL"), or
25+
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26+
* in which case the provisions of the GPL or the LGPL are applicable instead
27+
* of those above. If you wish to allow use of your version of this file only
28+
* under the terms of either the GPL or the LGPL, and not to allow others to
29+
* use your version of this file under the terms of the MPL, indicate your
30+
* decision by deleting the provisions above and replace them with the notice
31+
* and other provisions required by the GPL or the LGPL. If you do not delete
32+
* the provisions above, a recipient may use your version of this file under
33+
* the terms of any one of the MPL, the GPL or the LGPL.
34+
*
35+
* ***** END LICENSE BLOCK ***** */
36+
37+
#include "domstubs.idl"
38+
interface nsIDOMDesktopNotificationCenter;
39+
40+
/**
41+
* Property that extends the navigator object.
42+
*/
43+
[scriptable, uuid(EC2E6E4F-2F65-439C-B6C6-27E89B03B348)]
44+
interface nsIDOMNavigatorDesktopNotification : nsISupports
45+
{
46+
readonly attribute nsIDOMDesktopNotificationCenter mozNotification;
47+
};

0 commit comments

Comments
 (0)