OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Use the <code>chrome.notificationProvider</code> API to intercept | 5 // Use the <code>chrome.notificationProvider</code> API to intercept |
6 // notifications that would otherwise go into the Chrome Notification Center, | 6 // notifications that would otherwise go into the Chrome Notification Center, |
7 // get notifiers' information, and inform notifiers about users' actions on the | 7 // get notifiers' information, and inform notifiers about users' actions on the |
8 // notifications. | 8 // notifications. |
9 namespace notificationProvider { | 9 namespace notificationProvider { |
10 | 10 |
11 // TODO(liyanhou): Use notifications.PermissionLevel everywhere and delete | 11 // TODO(liyanhou): Use notifications.PermissionLevel everywhere and delete |
12 // this type. See http://crbug.com/398266. | 12 // this type. See http://crbug.com/398266. |
13 | 13 |
14 // whether notifications from this notifier is permitted or blocked. | 14 // whether notifications from this notifier is permitted or blocked. |
15 enum NotifierPermissionLevel { | 15 enum NotifierPermissionLevel { |
16 // User has elected to show notifications from the notifier. | 16 // User has elected to show notifications from the notifier. |
17 // This is the default at install time. | 17 // This is the default at install time. |
18 granted, | 18 granted, |
19 | 19 |
20 // User has elected not to show notifications from the notifier. | 20 // User has elected not to show notifications from the notifier. |
21 denied | 21 denied |
22 }; | 22 }; |
23 | 23 |
24 enum NotifierType { | |
25 // Notifiers that are extensions or applications. | |
26 application, | |
27 | |
28 // Notifiers that are webistes. | |
29 web | |
30 }; | |
31 | |
24 dictionary Notifier { | 32 dictionary Notifier { |
33 // Id of the notifier. | |
34 DOMString notifierId; | |
35 | |
36 // Type of the notifier. | |
37 NotifierType type; | |
38 | |
25 // Name of the notifier. | 39 // Name of the notifier. |
26 DOMString name; | 40 DOMString name; |
27 | 41 |
28 // Icon of the notifier. | 42 // Icon of the notifier. |
29 notifications.NotificationBitmap notifierIcon; | 43 notifications.NotificationBitmap notifierIcon; |
30 | 44 |
31 // Permission level of the notifier. | 45 // Permission level of the notifier. |
32 NotifierPermissionLevel permissionLevel; | 46 NotifierPermissionLevel permissionLevel; |
33 | 47 |
34 // If a notifier has advanced settings. | 48 // If a notifier has advanced settings. |
35 boolean hasSettings; | 49 boolean hasSettings; |
36 }; | 50 }; |
37 | 51 |
38 callback NotifyOnClearedCallback = void (boolean wasCleared); | 52 callback NotifyOnClearedCallback = void (boolean wasCleared); |
39 | 53 |
40 callback NotifyOnClickedCallback = void (boolean matchExists); | 54 callback NotifyOnClickedCallback = void (boolean matchExists); |
41 | 55 |
42 callback NotifyOnButtonClickedCallback = void (boolean matchExists); | 56 callback NotifyOnButtonClickedCallback = void (boolean matchExists); |
43 | 57 |
44 callback NotifyOnPermissionLevelChangedCallback = | 58 callback NotifyOnPermissionLevelChangedCallback = void (boolean wasChanged); |
45 void (boolean notifierExists); | |
46 | 59 |
47 callback NotifyOnShowSettingsCallback = void (boolean notifierExists); | 60 callback NotifyOnShowSettingsCallback = void (boolean hasSettings); |
48 | 61 |
49 callback GetNotifierCallback = void (Notifier notifier); | 62 callback GetNotifierCallback = void (Notifier notifier); |
50 | 63 |
51 callback GetAllNotifiersCallback = void (Notifier[] notifiers); | 64 callback GetAllNotifiersCallback = void (Notifier[] notifiers); |
52 | 65 |
53 interface Functions { | 66 interface Functions { |
54 // Inform the notifier that the user cleared a notification sent from that | 67 // Inform the notifier that the user cleared a notification sent from that |
55 // notifier. | 68 // notifier. |
56 // |notifierId|: The id of the notifier that sent the notification. | 69 // |notifierId|: The id of the notifier that sent the notification. |
57 // |notificationId|: The id of the notification that was closed. | 70 // |notificationId|: The id of the notification that was closed. |
(...skipping 19 matching lines...) Expand all Loading... | |
77 // |buttonIndex|: The index of the button that was clicked. | 90 // |buttonIndex|: The index of the button that was clicked. |
78 // |callback|: Called to indicate whether a matching notification existed. | 91 // |callback|: Called to indicate whether a matching notification existed. |
79 static void notifyOnButtonClicked(DOMString notifierId, | 92 static void notifyOnButtonClicked(DOMString notifierId, |
80 DOMString notificationId, | 93 DOMString notificationId, |
81 long buttonIndex, | 94 long buttonIndex, |
82 NotifyOnButtonClickedCallback callback); | 95 NotifyOnButtonClickedCallback callback); |
83 | 96 |
84 // Inform the notifier that the user changed the permission level of that | 97 // Inform the notifier that the user changed the permission level of that |
85 // notifier. | 98 // notifier. |
86 // |notifierId|: The id of the notifier that sent the notification. | 99 // |notifierId|: The id of the notifier that sent the notification. |
100 // |notifierType|: The type of the notifier that sent the notification. | |
87 // |level|: The perission level of the notifier | 101 // |level|: The perission level of the notifier |
88 // |callback|: Called to indicate whether the notifier existed. | 102 // |callback|: Called to indicate whether the permission level was changed. |
89 static void notifyOnPermissionLevelChanged( | 103 static void notifyOnPermissionLevelChanged( |
90 DOMString notifierId, | 104 DOMString notifierId, |
105 NotifierType notifierType, | |
91 NotifierPermissionLevel level, | 106 NotifierPermissionLevel level, |
92 NotifyOnPermissionLevelChangedCallback callback); | 107 NotifyOnPermissionLevelChangedCallback callback); |
93 | 108 |
94 // Inform the notifier that the user chose to see advanced settings of that | 109 // Inform the notifier that the user chose to see advanced settings of that |
95 // notifier. | 110 // notifier. |
96 // |notifierId|: The id of the notifier that sent the notification. | 111 // |notifierId|: The id of the notifier that sent the notification. |
97 // |callback|: Called to indicate whether a matching notifier existed. | 112 // |notifierType|: The type of the notifier that sent the notification. |
113 // |callback|: Called to indicate whether the notifier has extra settings. | |
98 static void notifyOnShowSettings(DOMString notifierId, | 114 static void notifyOnShowSettings(DOMString notifierId, |
115 NotifierType notifierType, | |
Pete Williamson
2014/08/13 19:54:01
Why do we need notifierType here? Won't the notif
liyanhou
2014/08/14 16:15:24
An object of Notifier dictionary type contains Not
| |
99 NotifyOnShowSettingsCallback callback); | 116 NotifyOnShowSettingsCallback callback); |
100 | 117 |
101 // To get a notifier from it's notifier ID. | 118 // To get a notifier from it's notifier ID. |
102 // |callback|: Returns the notifier object of the given ID. | 119 // |callback|: Returns the notifier object of the given ID. |
103 static void getNotifier(GetNotifierCallback callback); | 120 static void getNotifier(GetNotifierCallback callback); |
104 | 121 |
105 // To get all the notifiers that could send notifications. | 122 // To get all the notifiers that could send notifications. |
106 // |callback|: Returns the set of notifiers currently in the system. | 123 // |callback|: Returns the set of notifiers currently in the system. |
107 static void getAllNotifiers(GetAllNotifiersCallback callback); | 124 static void getAllNotifiers(GetAllNotifiersCallback callback); |
108 }; | 125 }; |
(...skipping 14 matching lines...) Expand all Loading... | |
123 static void onUpdated(DOMString notifierId, | 140 static void onUpdated(DOMString notifierId, |
124 DOMString notificationId, | 141 DOMString notificationId, |
125 notifications.NotificationOptions options); | 142 notifications.NotificationOptions options); |
126 | 143 |
127 // A notification is cleared by the notifier. | 144 // A notification is cleared by the notifier. |
128 // |notifierId|: The id of the notifier that cleared the notification. | 145 // |notifierId|: The id of the notifier that cleared the notification. |
129 // |notificationId|: The id of the cleared notification. | 146 // |notificationId|: The id of the cleared notification. |
130 static void onCleared(DOMString notifierId, DOMString notificationId); | 147 static void onCleared(DOMString notifierId, DOMString notificationId); |
131 }; | 148 }; |
132 }; | 149 }; |
OLD | NEW |