Chromium Code Reviews| 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 | |
| 70 void DisplayNow(NotificationCommon::Type notification_type, | |
| 71 const std::string& notification_id, | |
| 72 const Notification& notification); | |
| 73 void CloseNow(NotificationCommon::Type notification_type, | |
| 74 const std::string& notification_id); | |
| 75 void GetDisplayedNow(const DisplayedNotificationsCallback& callback); | |
|
Peter Beverloo
2017/04/25 15:16:55
These three methods don't exist in the .cc
Tom (Use chromium acct)
2017/04/25 18:35:21
Oops, removed
| |
| 76 | |
| 63 Profile* profile_; | 77 Profile* profile_; |
| 78 | |
| 64 NotificationPlatformBridge* notification_bridge_; | 79 NotificationPlatformBridge* notification_bridge_; |
| 80 // Is |notification_bridge_| ready to be used? | |
| 81 bool notification_bridge_connected_; | |
| 82 | |
| 83 // MessageCenterDisplayService to fallback on if initialization of | |
| 84 // |notification_bridge_| failed. | |
| 85 std::unique_ptr<MessageCenterDisplayService> message_center_display_service_; | |
| 86 | |
| 87 // Tasks that need to be run once we have the initialization status | |
| 88 // for |notification_bridge_|. | |
| 89 std::queue<base::Closure> actions_; | |
|
Peter Beverloo
2017/04/25 15:16:55
nit: base::OnceClosure
Tom (Use chromium acct)
2017/04/25 18:35:21
Done.
| |
| 90 | |
| 65 std::map<NotificationCommon::Type, std::unique_ptr<NotificationHandler>> | 91 std::map<NotificationCommon::Type, std::unique_ptr<NotificationHandler>> |
| 66 notification_handlers_; | 92 notification_handlers_; |
| 67 | 93 |
| 94 base::WeakPtrFactory<NativeNotificationDisplayService> weak_factory_; | |
| 95 | |
| 68 DISALLOW_COPY_AND_ASSIGN(NativeNotificationDisplayService); | 96 DISALLOW_COPY_AND_ASSIGN(NativeNotificationDisplayService); |
| 69 }; | 97 }; |
| 70 | 98 |
| 71 #endif // CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ | 99 #endif // CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ |
| OLD | NEW |