OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
| 10 #include <queue> |
10 #include <set> | 11 #include <set> |
11 #include <string> | 12 #include <string> |
12 | 13 |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" |
14 #include "chrome/browser/notifications/notification_common.h" | 16 #include "chrome/browser/notifications/notification_common.h" |
15 #include "chrome/browser/notifications/notification_display_service.h" | 17 #include "chrome/browser/notifications/notification_display_service.h" |
16 | 18 |
17 namespace base { | 19 namespace base { |
18 class NullableString16; | 20 class NullableString16; |
19 } | 21 } |
20 | 22 |
| 23 class MessageCenterDisplayService; |
21 class Notification; | 24 class Notification; |
22 class NotificationHandler; | 25 class NotificationHandler; |
23 class NotificationPlatformBridge; | 26 class NotificationPlatformBridge; |
24 class Profile; | 27 class Profile; |
25 | 28 |
26 // A class to display and interact with notifications in native notification | 29 // A class to display and interact with notifications in native notification |
27 // centers on platforms that support it. | 30 // centers on platforms that support it. |
28 class NativeNotificationDisplayService : public NotificationDisplayService { | 31 class NativeNotificationDisplayService : public NotificationDisplayService { |
29 public: | 32 public: |
30 NativeNotificationDisplayService( | 33 NativeNotificationDisplayService( |
(...skipping 22 matching lines...) Expand all Loading... |
53 void AddNotificationHandler(NotificationCommon::Type notification_type, | 56 void AddNotificationHandler(NotificationCommon::Type notification_type, |
54 std::unique_ptr<NotificationHandler> handler); | 57 std::unique_ptr<NotificationHandler> handler); |
55 | 58 |
56 // Removes an implementation added via |AddNotificationHandler|. | 59 // Removes an implementation added via |AddNotificationHandler|. |
57 void RemoveNotificationHandler(NotificationCommon::Type notification_type); | 60 void RemoveNotificationHandler(NotificationCommon::Type notification_type); |
58 | 61 |
59 private: | 62 private: |
60 NotificationHandler* GetNotificationHandler( | 63 NotificationHandler* GetNotificationHandler( |
61 NotificationCommon::Type notification_type); | 64 NotificationCommon::Type notification_type); |
62 | 65 |
| 66 // Called by |notification_bridge_| when it is finished |
| 67 // initializing. |success| indicates it is ready to be used. |
| 68 void OnNotificationPlatformBridgeInitialized(bool success); |
| 69 |
63 Profile* profile_; | 70 Profile* profile_; |
| 71 |
64 NotificationPlatformBridge* notification_bridge_; | 72 NotificationPlatformBridge* notification_bridge_; |
| 73 // Is |notification_bridge_| ready to be used? |
| 74 bool notification_bridge_connected_; |
| 75 |
| 76 // MessageCenterDisplayService to fallback on if initialization of |
| 77 // |notification_bridge_| failed. |
| 78 std::unique_ptr<MessageCenterDisplayService> message_center_display_service_; |
| 79 |
| 80 // Tasks that need to be run once we have the initialization status |
| 81 // for |notification_bridge_|. |
| 82 std::queue<base::OnceClosure> actions_; |
| 83 |
65 std::map<NotificationCommon::Type, std::unique_ptr<NotificationHandler>> | 84 std::map<NotificationCommon::Type, std::unique_ptr<NotificationHandler>> |
66 notification_handlers_; | 85 notification_handlers_; |
67 | 86 |
| 87 base::WeakPtrFactory<NativeNotificationDisplayService> weak_factory_; |
| 88 |
68 DISALLOW_COPY_AND_ASSIGN(NativeNotificationDisplayService); | 89 DISALLOW_COPY_AND_ASSIGN(NativeNotificationDisplayService); |
69 }; | 90 }; |
70 | 91 |
71 #endif // CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ | 92 #endif // CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ |
OLD | NEW |