OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef JINGLE_NOTIFIER_LISTENER_NON_BLOCKING_PUSH_CLIENT_OBSERVER_H_ | 5 #ifndef JINGLE_NOTIFIER_LISTENER_NON_BLOCKING_PUSH_CLIENT_OBSERVER_H_ |
6 #define JINGLE_NOTIFIER_LISTENER_NON_BLOCKING_PUSH_CLIENT_OBSERVER_H_ | 6 #define JINGLE_NOTIFIER_LISTENER_NON_BLOCKING_PUSH_CLIENT_OBSERVER_H_ |
7 | 7 |
8 #include "jingle/notifier/listener/notification_defines.h" | 8 #include "jingle/notifier/listener/notification_defines.h" |
9 | 9 |
10 namespace notifier { | 10 namespace notifier { |
11 | 11 |
12 // A PushClientObserver is notified whenever an incoming notification | 12 enum NotificationsDisabledReason { |
13 // is received or when the state of the push client changes. | 13 // There is an underlying transient problem (e.g., network- or |
| 14 // XMPP-related). |
| 15 TRANSIENT_NOTIFICATION_ERROR, |
| 16 DEFAULT_NOTIFICATION_ERROR = TRANSIENT_NOTIFICATION_ERROR, |
| 17 // Our credentials have been rejected. |
| 18 NOTIFICATION_CREDENTIALS_REJECTED, |
| 19 // No error (useful for avoiding keeping a separate bool for |
| 20 // notifications enabled/disabled). |
| 21 NO_NOTIFICATION_ERROR |
| 22 }; |
| 23 |
| 24 // A PushClientObserver is notified when notifications are enabled or |
| 25 // disabled, and when a notification is received. |
14 class PushClientObserver { | 26 class PushClientObserver { |
15 protected: | 27 protected: |
16 virtual ~PushClientObserver(); | 28 virtual ~PushClientObserver(); |
17 | 29 |
18 public: | 30 public: |
19 // Called when the state of the push client changes. If | 31 // Called when notifications are enabled. |
20 // |notifications_enabled| is true, that means notifications can be | 32 virtual void OnNotificationsEnabled() = 0; |
21 // sent and received freely. If it is false, that means no | 33 |
22 // notifications can be sent or received. | 34 // Called when notifications are disabled, with the reason (not |
23 virtual void OnNotificationStateChange(bool notifications_enabled) = 0; | 35 // equal to NO_ERROR) in |reason|. |
| 36 virtual void OnNotificationsDisabled( |
| 37 NotificationsDisabledReason reason) = 0; |
24 | 38 |
25 // Called when a notification is received. The details of the | 39 // Called when a notification is received. The details of the |
26 // notification are in |notification|. | 40 // notification are in |notification|. |
27 virtual void OnIncomingNotification(const Notification& notification) = 0; | 41 virtual void OnIncomingNotification(const Notification& notification) = 0; |
28 }; | 42 }; |
29 | 43 |
30 } // namespace notifier | 44 } // namespace notifier |
31 | 45 |
32 #endif // JINGLE_NOTIFIER_LISTENER_NON_BLOCKING_PUSH_CLIENT_OBSERVER_H_ | 46 #endif // JINGLE_NOTIFIER_LISTENER_NON_BLOCKING_PUSH_CLIENT_OBSERVER_H_ |
OLD | NEW |