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