OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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. |
| 4 |
| 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 |
| 8 // notifications. |
| 9 namespace notificationProvider { |
| 10 |
| 11 // TODO(liyanhou): Use notifications.PermissionLevel everywhere and delete |
| 12 // this type. See http://crbug.com/398266. |
| 13 |
| 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. |
| 18 granted, |
| 19 |
| 20 // User has elected not to show notifications from the notifier. |
| 21 denied |
| 22 }; |
| 23 |
| 24 dictionary Notifier { |
| 25 // Name of the notifier. |
| 26 DOMString name; |
| 27 |
| 28 // Icon of the notifier. |
| 29 notifications.NotificationBitmap notifierIcon; |
| 30 |
| 31 // Permission level of the notifier. |
| 32 NotifierPermissionLevel permissionLevel; |
| 33 |
| 34 // If a notifier has advanced settings. |
| 35 boolean hasSettings; |
| 36 }; |
| 37 |
| 38 callback NotifyOnClearedCallback = void (boolean wasCleared); |
| 39 |
| 40 callback NotifyOnClickedCallback = void (boolean matchExists); |
| 41 |
| 42 callback NotifyOnButtonClickedCallback = void (boolean matchExists); |
| 43 |
| 44 callback NotifyOnPermissionLevelChangedCallback = |
| 45 void (boolean notifierExists); |
| 46 |
| 47 callback NotifyOnShowSettingsCallback = void (boolean notifierExists); |
| 48 |
| 49 callback GetNotifierCallback = void (Notifier notifier); |
| 50 |
| 51 callback GetAllNotifiersCallback = void (Notifier[] notifiers); |
| 52 |
| 53 interface Functions { |
| 54 // Inform the notifier that the user cleared a notification sent from that |
| 55 // notifier. |
| 56 // |notifierId|: The id of the notifier that sent the notification. |
| 57 // |notificationId|: The id of the notification that was closed. |
| 58 // |callback|: Called to indicate whether a matching notification existed. |
| 59 static void notifyOnCleared(DOMString notifierId, |
| 60 DOMString notificationId, |
| 61 NotifyOnClearedCallback callback); |
| 62 |
| 63 // Inform the notifier that the user clicked in a non-button area of a |
| 64 // notification sent from that notifier. |
| 65 // |notifierId|: The id of the notifier that sent the notification. |
| 66 // |notificationId|: The id of the notification that was clicked on. |
| 67 // |callback|: Called to indicate whether a matching notification existed. |
| 68 static void notifyOnClicked(DOMString notifierId, |
| 69 DOMString notificationId, |
| 70 NotifyOnClickedCallback callback); |
| 71 |
| 72 // Inform the notifier that the user pressed a button in the notification |
| 73 // sent from that notifier. |
| 74 // |notifierId|: The id of the notifier that sent the notification. |
| 75 // |notificationId|: The id of the notification that was clicked on its |
| 76 // button. |
| 77 // |buttonIndex|: The index of the button that was clicked. |
| 78 // |callback|: Called to indicate whether a matching notification existed. |
| 79 static void notifyOnButtonClicked(DOMString notifierId, |
| 80 DOMString notificationId, |
| 81 long buttonIndex, |
| 82 NotifyOnButtonClickedCallback callback); |
| 83 |
| 84 // Inform the notifier that the user changed the permission level of that |
| 85 // notifier. |
| 86 // |notifierId|: The id of the notifier that sent the notification. |
| 87 // |level|: The perission level of the notifier |
| 88 // |callback|: Called to indicate whether the notifier existed. |
| 89 static void notifyOnPermissionLevelChanged( |
| 90 DOMString notifierId, |
| 91 NotifierPermissionLevel level, |
| 92 NotifyOnPermissionLevelChangedCallback callback); |
| 93 |
| 94 // Inform the notifier that the user chose to see advanced settings of that |
| 95 // notifier. |
| 96 // |notifierId|: The id of the notifier that sent the notification. |
| 97 // |callback|: Called to indicate whether a matching notifier existed. |
| 98 static void notifyOnShowSettings(DOMString notifierId, |
| 99 NotifyOnShowSettingsCallback callback); |
| 100 |
| 101 // To get a notifier from it's notifier ID. |
| 102 // |callback|: Returns the notifier object of the given ID. |
| 103 static void getNotifier(GetNotifierCallback callback); |
| 104 |
| 105 // To get all the notifiers that could send notifications. |
| 106 // |callback|: Returns the set of notifiers currently in the system. |
| 107 static void getAllNotifiers(GetAllNotifiersCallback callback); |
| 108 }; |
| 109 |
| 110 interface Events { |
| 111 // A new notification is created. |
| 112 // |notifierId|: The id of the notifier that sent the new notification. |
| 113 // |notificationId|: The id of the newly created notification. |
| 114 // |options|: The content of the notification: type, title, message etc. |
| 115 static void onCreated(DOMString notifierId, |
| 116 DOMString notificationId, |
| 117 notifications.NotificationOptions options); |
| 118 |
| 119 // A notification is updated by the notifier. |
| 120 // |notifierId|: The id of the notifier that sent the updated notification. |
| 121 // |notificationId|: The id of the updated notification. |
| 122 // |options|: The content of the notification: type, title, message etc. |
| 123 static void onUpdated(DOMString notifierId, |
| 124 DOMString notificationId, |
| 125 notifications.NotificationOptions options); |
| 126 |
| 127 // A notification is cleared by the notifier. |
| 128 // |notifierId|: The id of the notifier that cleared the notification. |
| 129 // |notificationId|: The id of the cleared notification. |
| 130 static void onCleared(DOMString notifierId, DOMString notificationId); |
| 131 }; |
| 132 }; |
OLD | NEW |