This repository was archived by the owner on Jul 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathNotification.h
More file actions
93 lines (70 loc) · 2.65 KB
/
Copy pathNotification.h
File metadata and controls
93 lines (70 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* 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_notification_h__
#define mozilla_dom_notification_h__
#include "mozilla/dom/NotificationBinding.h"
#include "nsDOMEventTargetHelper.h"
#include "nsIObserver.h"
namespace mozilla {
namespace dom {
class NotificationObserver;
class Notification : public nsDOMEventTargetHelper
{
friend class NotificationTask;
friend class NotificationPermissionRequest;
friend class NotificationObserver;
public:
IMPL_EVENT_HANDLER(click)
IMPL_EVENT_HANDLER(show)
IMPL_EVENT_HANDLER(error)
IMPL_EVENT_HANDLER(close)
Notification(const nsAString& aTitle, const nsAString& aBody,
NotificationDirection aDir, const nsAString& aLang,
const nsAString& aTag, const nsAString& aIconUrl);
static already_AddRefed<Notification> Constructor(const GlobalObject& aGlobal,
const nsAString& aTitle,
const NotificationOptions& aOption,
ErrorResult& aRv);
static void RequestPermission(const GlobalObject& aGlobal,
const Optional<OwningNonNull<NotificationPermissionCallback> >& aCallback,
ErrorResult& aRv);
static NotificationPermission GetPermission(const GlobalObject& aGlobal,
ErrorResult& aRv);
void Close();
static bool PrefEnabled();
nsPIDOMWindow* GetParentObject()
{
return GetOwner();
}
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
protected:
nsresult ShowInternal();
nsresult CloseInternal();
static NotificationPermission GetPermissionInternal(nsISupports* aGlobal,
ErrorResult& rv);
static const nsString DirectionToString(NotificationDirection aDirection)
{
switch (aDirection) {
case NotificationDirectionValues::Ltr:
return NS_LITERAL_STRING("ltr");
case NotificationDirectionValues::Rtl:
return NS_LITERAL_STRING("rtl");
default:
return NS_LITERAL_STRING("auto");
}
}
nsresult GetAlertName(nsString& aAlertName);
nsString mTitle;
nsString mBody;
NotificationDirection mDir;
nsString mLang;
nsString mTag;
nsString mIconUrl;
bool mIsClosed;
static uint32_t sCount;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_notification_h__