1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Use the <code>chrome.notificationProvider</code> API to intercept
6 // notifications that would otherwise go into the Chrome Notification Center,
7 // get notifiers' information, and inform notifiers about users' actions on the
9 namespace notificationProvider
{
11 // TODO(liyanhou): Use notifications.PermissionLevel everywhere and delete
12 // this type. See http://crbug.com/398266.
14 // whether notifications from this notifier is permitted or blocked.
15 enum NotifierPermissionLevel
{
16 // User has elected to show notifications from the notifier.
17 // This is the default at install time.
20 // User has elected not to show notifications from the notifier.
25 // Notifiers that are extensions or applications.
28 // Notifiers that are webistes.
33 // Id of the notifier.
36 // Type of the notifier.
39 // Name of the notifier.
42 // Icon of the notifier.
43 notifications.NotificationBitmap notifierIcon
;
45 // Permission level of the notifier.
46 NotifierPermissionLevel permissionLevel
;
48 // If a notifier has advanced settings.
52 callback NotifyOnClearedCallback
= void (boolean wasCleared
);
54 callback NotifyOnClickedCallback
= void (boolean matchExists
);
56 callback NotifyOnButtonClickedCallback
= void (boolean matchExists
);
58 callback NotifyOnPermissionLevelChangedCallback
= void (boolean wasChanged
);
60 callback NotifyOnShowSettingsCallback
= void (boolean hasSettings
);
62 callback GetNotifierCallback
= void (Notifier notifier
);
64 callback GetAllNotifiersCallback
= void (Notifier
[] notifiers
);
67 // Inform the notifier that the user cleared a notification sent from that
69 // |notifierId|: The id of the notifier that sent the notification.
70 // |notificationId|: The id of the notification that was closed.
71 // |callback|: Called to indicate whether a matching notification existed.
72 static
void notifyOnCleared
(DOMString notifierId
,
73 DOMString notificationId
,
74 NotifyOnClearedCallback
callback);
76 // Inform the notifier that the user clicked in a non-button area of a
77 // notification sent from that notifier.
78 // |notifierId|: The id of the notifier that sent the notification.
79 // |notificationId|: The id of the notification that was clicked on.
80 // |callback|: Called to indicate whether a matching notification existed.
81 static
void notifyOnClicked
(DOMString notifierId
,
82 DOMString notificationId
,
83 NotifyOnClickedCallback
callback);
85 // Inform the notifier that the user pressed a button in the notification
86 // sent from that notifier.
87 // |notifierId|: The id of the notifier that sent the notification.
88 // |notificationId|: The id of the notification that was clicked on its
90 // |buttonIndex|: The index of the button that was clicked.
91 // |callback|: Called to indicate whether a matching notification existed.
92 static
void notifyOnButtonClicked
(DOMString notifierId
,
93 DOMString notificationId
,
95 NotifyOnButtonClickedCallback
callback);
97 // Inform the notifier that the user changed the permission level of that
99 // |notifierId|: The id of the notifier that sent the notification.
100 // |notifierType|: The type of the notifier that sent the notification.
101 // |level|: The perission level of the notifier
102 // |callback|: Called to indicate whether the permission level was changed.
103 static
void notifyOnPermissionLevelChanged
(
104 DOMString notifierId
,
105 NotifierType notifierType
,
106 NotifierPermissionLevel level
,
107 NotifyOnPermissionLevelChangedCallback
callback);
109 // Inform the notifier that the user chose to see advanced settings of that
111 // |notifierId|: The id of the notifier that sent the notification.
112 // |notifierType|: The type of the notifier that sent the notification.
113 // |callback|: Called to indicate whether the notifier has extra settings.
114 static
void notifyOnShowSettings
(DOMString notifierId
,
115 NotifierType notifierType
,
116 NotifyOnShowSettingsCallback
callback);
118 // To get a notifier from it's notifier ID.
119 // |callback|: Returns the notifier object of the given ID.
120 static
void getNotifier
(GetNotifierCallback
callback);
122 // To get all the notifiers that could send notifications.
123 // |callback|: Returns the set of notifiers currently in the system.
124 static
void getAllNotifiers
(GetAllNotifiersCallback
callback);
128 // A new notification is created.
129 // |notifierId|: The id of the notifier that sent the new notification.
130 // |notificationId|: The id of the newly created notification.
131 // |options|: The content of the notification: type, title, message etc.
132 static
void onCreated
(DOMString notifierId
,
133 DOMString notificationId
,
134 notifications.NotificationOptions options
);
136 // A notification is updated by the notifier.
137 // |notifierId|: The id of the notifier that sent the updated notification.
138 // |notificationId|: The id of the updated notification.
139 // |options|: The content of the notification: type, title, message etc.
140 static
void onUpdated
(DOMString notifierId
,
141 DOMString notificationId
,
142 notifications.NotificationOptions options
);
144 // A notification is cleared by the notifier.
145 // |notifierId|: The id of the notifier that cleared the notification.
146 // |notificationId|: The id of the cleared notification.
147 static
void onCleared
(DOMString notifierId
, DOMString notificationId
);