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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.notificationProvider</code> API to intercept
// notifications that would otherwise go into the Chrome Notification Center,
// get notifiers' information, and inform notifiers about users' actions on the
// notifications.
namespace notificationProvider {
// TODO(liyanhou): Use notifications.PermissionLevel everywhere and delete
// this type. See http://crbug.com/398266.
// whether notifications from this notifier is permitted or blocked.
enum NotifierPermissionLevel {
// User has elected to show notifications from the notifier.
// This is the default at install time.
granted,
// User has elected not to show notifications from the notifier.
denied
};
enum NotifierType {
// Notifiers that are extensions or applications.
application,
// Notifiers that are webistes.
web
};
dictionary Notifier {
// Id of the notifier.
DOMString notifierId;
// Type of the notifier.
NotifierType type;
// Name of the notifier.
DOMString name;
// Icon of the notifier.
notifications.NotificationBitmap notifierIcon;
// Permission level of the notifier.
NotifierPermissionLevel permissionLevel;
// If a notifier has advanced settings.
boolean hasSettings;
};
callback NotifyOnClearedCallback = void (boolean wasCleared);
callback NotifyOnClickedCallback = void (boolean matchExists);
callback NotifyOnButtonClickedCallback = void (boolean matchExists);
callback NotifyOnPermissionLevelChangedCallback = void (boolean wasChanged);
callback NotifyOnShowSettingsCallback = void (boolean hasSettings);
callback GetNotifierCallback = void (Notifier notifier);
callback GetAllNotifiersCallback = void (Notifier[] notifiers);
interface Functions {
// Inform the notifier that the user cleared a notification sent from that
// notifier.
// |notifierId|: The id of the notifier that sent the notification.
// |notificationId|: The id of the notification that was closed.
// |callback|: Called to indicate whether a matching notification existed.
static void notifyOnCleared(DOMString notifierId,
DOMString notificationId,
NotifyOnClearedCallback callback);
// Inform the notifier that the user clicked in a non-button area of a
// notification sent from that notifier.
// |notifierId|: The id of the notifier that sent the notification.
// |notificationId|: The id of the notification that was clicked on.
// |callback|: Called to indicate whether a matching notification existed.
static void notifyOnClicked(DOMString notifierId,
DOMString notificationId,
NotifyOnClickedCallback callback);
// Inform the notifier that the user pressed a button in the notification
// sent from that notifier.
// |notifierId|: The id of the notifier that sent the notification.
// |notificationId|: The id of the notification that was clicked on its
// button.
// |buttonIndex|: The index of the button that was clicked.
// |callback|: Called to indicate whether a matching notification existed.
static void notifyOnButtonClicked(DOMString notifierId,
DOMString notificationId,
long buttonIndex,
NotifyOnButtonClickedCallback callback);
// Inform the notifier that the user changed the permission level of that
// notifier.
// |notifierId|: The id of the notifier that sent the notification.
// |notifierType|: The type of the notifier that sent the notification.
// |level|: The perission level of the notifier
// |callback|: Called to indicate whether the permission level was changed.
static void notifyOnPermissionLevelChanged(
DOMString notifierId,
NotifierType notifierType,
NotifierPermissionLevel level,
NotifyOnPermissionLevelChangedCallback callback);
// Inform the notifier that the user chose to see advanced settings of that
// notifier.
// |notifierId|: The id of the notifier that sent the notification.
// |notifierType|: The type of the notifier that sent the notification.
// |callback|: Called to indicate whether the notifier has extra settings.
static void notifyOnShowSettings(DOMString notifierId,
NotifierType notifierType,
NotifyOnShowSettingsCallback callback);
// To get a notifier from it's notifier ID.
// |callback|: Returns the notifier object of the given ID.
static void getNotifier(GetNotifierCallback callback);
// To get all the notifiers that could send notifications.
// |callback|: Returns the set of notifiers currently in the system.
static void getAllNotifiers(GetAllNotifiersCallback callback);
};
interface Events {
// A new notification is created.
// |notifierId|: The id of the notifier that sent the new notification.
// |notificationId|: The id of the newly created notification.
// |options|: The content of the notification: type, title, message etc.
static void onCreated(DOMString notifierId,
DOMString notificationId,
notifications.NotificationOptions options);
// A notification is updated by the notifier.
// |notifierId|: The id of the notifier that sent the updated notification.
// |notificationId|: The id of the updated notification.
// |options|: The content of the notification: type, title, message etc.
static void onUpdated(DOMString notifierId,
DOMString notificationId,
notifications.NotificationOptions options);
// A notification is cleared by the notifier.
// |notifierId|: The id of the notifier that cleared the notification.
// |notificationId|: The id of the cleared notification.
static void onCleared(DOMString notifierId, DOMString notificationId);
};
};
|